summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2001-01-10 17:17:53 +0000
committerRalf Baechle <ralf@linux-mips.org>2001-01-10 17:17:53 +0000
commitb2ad5f821b1381492d792ca10b1eb7a107b48f14 (patch)
tree954a648692e7da983db1d2470953705f6a729264 /drivers/acpi/tables
parentc9c06167e7933d93a6e396174c68abf242294abb (diff)
Merge with Linux 2.4.0-prerelease. Big Makefile rewrite, test your
Makefiles.
Diffstat (limited to 'drivers/acpi/tables')
-rw-r--r--drivers/acpi/tables/Makefile14
-rw-r--r--drivers/acpi/tables/tbconvrt.c553
-rw-r--r--drivers/acpi/tables/tbget.c303
-rw-r--r--drivers/acpi/tables/tbinstal.c97
-rw-r--r--drivers/acpi/tables/tbtable.c392
-rw-r--r--drivers/acpi/tables/tbutils.c22
-rw-r--r--drivers/acpi/tables/tbxface.c62
-rw-r--r--drivers/acpi/tables/tbxfroot.c214
8 files changed, 1178 insertions, 479 deletions
diff --git a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile
index edd897133..751ef5de8 100644
--- a/drivers/acpi/tables/Makefile
+++ b/drivers/acpi/tables/Makefile
@@ -2,26 +2,14 @@
# Makefile for all Linux ACPI interpreter subdirectories
#
-SUB_DIRS :=
-MOD_SUB_DIRS := $(SUB_DIRS)
-MOD_IN_SUB_DIRS :=
-ALL_SUB_DIRS := $(SUB_DIRS)
-
O_TARGET := ../$(shell basename `pwd`).o
-O_OBJS :=
-M_OBJS :=
-ACPI_OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
+obj-$(CONFIG_ACPI) := $(patsubst %.c,%.o,$(wildcard *.c))
EXTRA_CFLAGS += -I../include
EXTRA_CFLAGS += $(ACPI_CFLAGS)
-# if the interpreter is used, it overrides arch/i386/kernel/acpi.c
-ifeq ($(CONFIG_ACPI_INTERPRETER),y)
- O_OBJS := $(ACPI_OBJS)
-endif
-
include $(TOPDIR)/Rules.make
clean:
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
new file mode 100644
index 000000000..624926d27
--- /dev/null
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -0,0 +1,553 @@
+/******************************************************************************
+ *
+ * Module Name: tbconvrt - ACPI Table conversion utilities
+ * $Revision: 15 $
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 R. Byron Moore
+ *
+ * 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
+ */
+
+
+#include "acpi.h"
+#include "achware.h"
+#include "actables.h"
+#include "actbl.h"
+
+
+#define _COMPONENT TABLE_MANAGER
+ MODULE_NAME ("tbconvrt")
+
+
+/*
+ * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions)
+ *
+ * 1) Address space
+ * 2) Length in bytes -- convert to length in bits
+ * 3) Bit offset is zero
+ * 4) Reserved field is zero
+ * 5) Expand address to 64 bits
+ */
+#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) {a.address_space_id = (u8) d;\
+ a.register_bit_width = (u8) MUL_8 (b);\
+ a.register_bit_offset = 0;\
+ a.reserved = 0;\
+ a.address = (UINT64) c;}
+
+
+/* ACPI V1.0 entries -- address space is always I/O */
+
+#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ADDRESS_SPACE_SYSTEM_IO)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_convert_to_xsdt
+ *
+ * PARAMETERS:
+ *
+ * RETURN:
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_tb_convert_to_xsdt (
+ ACPI_TABLE_DESC *table_info,
+ u32 *number_of_tables)
+{
+ u32 table_size;
+ u32 pointer_size;
+ u32 i;
+ XSDT_DESCRIPTOR *new_table;
+
+
+#ifndef _IA64
+
+ if (acpi_gbl_RSDP->revision < 2) {
+ pointer_size = sizeof (u32);
+ }
+
+ else
+#endif
+ {
+ pointer_size = sizeof (UINT64);
+ }
+
+ /*
+ * Determine the number of tables pointed to by the RSDT/XSDT.
+ * This is defined by the ACPI Specification to be the number of
+ * pointers contained within the RSDT/XSDT. The size of the pointers
+ * is architecture-dependent.
+ */
+
+ table_size = table_info->pointer->length;
+ *number_of_tables = (table_size -
+ sizeof (ACPI_TABLE_HEADER)) / pointer_size;
+
+ /* Compute size of the converted XSDT */
+
+ table_size = (*number_of_tables * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER);
+
+
+ /* Allocate an XSDT */
+
+ new_table = acpi_cm_callocate (table_size);
+ if (!new_table) {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Copy the header and set the length */
+
+ MEMCPY (new_table, table_info->pointer, sizeof (ACPI_TABLE_HEADER));
+ new_table->header.length = table_size;
+
+ /* Copy the table pointers */
+
+ for (i = 0; i < *number_of_tables; i++) {
+ if (acpi_gbl_RSDP->revision < 2) {
+#ifdef _IA64
+ new_table->table_offset_entry[i] =
+ ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i];
+#else
+ new_table->table_offset_entry[i] =
+ ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i];
+#endif
+ }
+ else {
+ new_table->table_offset_entry[i] =
+ ((XSDT_DESCRIPTOR *) table_info->pointer)->table_offset_entry[i];
+ }
+ }
+
+
+ /* Delete the original table (either mapped or in a buffer) */
+
+ acpi_tb_delete_single_table (table_info);
+
+
+ /* Point the table descriptor to the new table */
+
+ table_info->pointer = (ACPI_TABLE_HEADER *) new_table;
+ table_info->base_pointer = (ACPI_TABLE_HEADER *) new_table;
+ table_info->length = table_size;
+ table_info->allocation = ACPI_MEM_ALLOCATED;
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_convert_table_fadt
+ *
+ * PARAMETERS:
+ *
+ * RETURN:
+ *
+ * DESCRIPTION:
+ * Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate
+ * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply
+ * copied to the intermediate FADT. The ACPI CA software uses this
+ * intermediate FADT. Thus a significant amount of special #ifdef
+ * type codeing is saved. This intermediate FADT will need to be
+ * freed at some point.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_tb_convert_table_fadt (void)
+{
+
+#ifdef _IA64
+ FADT_DESCRIPTOR_REV071 *FADT71;
+ u8 pm1_address_space;
+ u8 pm2_address_space;
+ u8 pm_timer_address_space;
+ u8 gpe0address_space;
+ u8 gpe1_address_space;
+#else
+ FADT_DESCRIPTOR_REV1 *FADT1;
+#endif
+
+ FADT_DESCRIPTOR_REV2 *FADT2;
+ ACPI_TABLE_DESC *table_desc;
+
+
+ /* Acpi_gbl_FADT is valid */
+ /* Allocate and zero the 2.0 buffer */
+
+ FADT2 = acpi_cm_callocate (sizeof (FADT_DESCRIPTOR_REV2));
+ if (FADT2 == NULL) {
+ return (AE_NO_MEMORY);
+ }
+
+
+ /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */
+ /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */
+
+ if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) {
+ /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */
+
+ *FADT2 = *((FADT_DESCRIPTOR_REV2*) acpi_gbl_FADT);
+
+ }
+
+ else {
+
+#ifdef _IA64
+ /*
+ * For the 64-bit case only, a revision ID less than V2.0 means the
+ * tables are the 0.71 extensions
+ */
+
+ /* The BIOS stored FADT should agree with Revision 0.71 */
+
+ FADT71 = (FADT_DESCRIPTOR_REV071 *) acpi_gbl_FADT;
+
+ /* Copy the table header*/
+
+ FADT2->header = FADT71->header;
+
+ /* Copy the common fields */
+
+ FADT2->sci_int = FADT71->sci_int;
+ FADT2->acpi_enable = FADT71->acpi_enable;
+ FADT2->acpi_disable = FADT71->acpi_disable;
+ FADT2->S4_bios_req = FADT71->S4_bios_req;
+ FADT2->plvl2_lat = FADT71->plvl2_lat;
+ FADT2->plvl3_lat = FADT71->plvl3_lat;
+ FADT2->day_alrm = FADT71->day_alrm;
+ FADT2->mon_alrm = FADT71->mon_alrm;
+ FADT2->century = FADT71->century;
+ FADT2->gpe1_base = FADT71->gpe1_base;
+
+ /*
+ * We still use the block length registers even though
+ * the GAS structure should obsolete them. This is because
+ * these registers are byte lengths versus the GAS which
+ * contains a bit width
+ */
+ FADT2->pm1_evt_len = FADT71->pm1_evt_len;
+ FADT2->pm1_cnt_len = FADT71->pm1_cnt_len;
+ FADT2->pm2_cnt_len = FADT71->pm2_cnt_len;
+ FADT2->pm_tm_len = FADT71->pm_tm_len;
+ FADT2->gpe0blk_len = FADT71->gpe0blk_len;
+ FADT2->gpe1_blk_len = FADT71->gpe1_blk_len;
+ FADT2->gpe1_base = FADT71->gpe1_base;
+
+ /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/
+
+ FADT2->wb_invd = FADT71->flush_cash;
+ FADT2->proc_c1 = FADT71->proc_c1;
+ FADT2->plvl2_up = FADT71->plvl2_up;
+ FADT2->pwr_button = FADT71->pwr_button;
+ FADT2->sleep_button = FADT71->sleep_button;
+ FADT2->fixed_rTC = FADT71->fixed_rTC;
+ FADT2->rtcs4 = FADT71->rtcs4;
+ FADT2->tmr_val_ext = FADT71->tmr_val_ext;
+ FADT2->dock_cap = FADT71->dock_cap;
+
+
+ /* We should not use these next two addresses */
+ /* Since our buffer is pre-zeroed nothing to do for */
+ /* the next three data items in the structure */
+ /* FADT2->Firmware_ctrl = 0; */
+ /* FADT2->Dsdt = 0; */
+
+ /* System Interrupt Model isn't used in ACPI 2.0*/
+ /* FADT2->Reserved1 = 0; */
+
+ /* This field is set by the OEM to convey the preferred */
+ /* power management profile to OSPM. It doesn't have any*/
+ /* 0.71 equivalence. Since we don't know what kind of */
+ /* 64-bit system this is, we will pick unspecified. */
+
+ FADT2->prefer_PM_profile = PM_UNSPECIFIED;
+
+
+ /* Port address of SMI command port */
+ /* We shouldn't use this port because IA64 doesn't */
+ /* have or use SMI. It has PMI. */
+
+ FADT2->smi_cmd = (u32)(FADT71->smi_cmd & 0xFFFFFFFF);
+
+
+ /* processor performance state control*/
+ /* The value OSPM writes to the SMI_CMD register to assume */
+ /* processor performance state control responsibility. */
+ /* There isn't any equivalence in 0.71 */
+ /* Again this should be meaningless for IA64 */
+ /* FADT2->Pstate_cnt = 0; */
+
+ /* The 32-bit Power management and GPE registers are */
+ /* not valid in IA-64 and we are not going to use them */
+ /* so leaving them pre-zeroed. */
+
+ /* Support for the _CST object and C States change notification.*/
+ /* This data item hasn't any 0.71 equivalence so leaving it zero.*/
+ /* FADT2->Cst_cnt = 0; */
+
+ /* number of flush strides that need to be read */
+ /* No 0.71 equivalence. Leave pre-zeroed. */
+ /* FADT2->Flush_size = 0; */
+
+ /* Processor's memory cache line width, in bytes */
+ /* No 0.71 equivalence. Leave pre-zeroed. */
+ /* FADT2->Flush_stride = 0; */
+
+ /* Processor’s duty cycle index in processor's P_CNT reg*/
+ /* No 0.71 equivalence. Leave pre-zeroed. */
+ /* FADT2->Duty_offset = 0; */
+
+ /* Processor’s duty cycle value bit width in P_CNT register.*/
+ /* No 0.71 equivalence. Leave pre-zeroed. */
+ /* FADT2->Duty_width = 0; */
+
+
+ /* Since there isn't any equivalence in 0.71 */
+ /* and since Big_sur had to support legacy */
+
+ FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES;
+
+ /* Copy to ACPI 2.0 64-BIT Extended Addresses */
+
+ FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl;
+ FADT2->Xdsdt = FADT71->dsdt;
+
+
+ /* Extract the address space IDs */
+
+ pm1_address_space = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE) >> 1);
+ pm2_address_space = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2);
+ pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3);
+ gpe0address_space = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE) >> 4);
+ gpe1_address_space = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE) >> 5);
+
+ /*
+ * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures,
+ * in this order:
+ *
+ * PM 1_a Events
+ * PM 1_b Events
+ * PM 1_a Control
+ * PM 1_b Control
+ * PM 2 Control
+ * PM Timer Control
+ * GPE Block 0
+ * GPE Block 1
+ */
+
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len, FADT71->pm_tmr_blk, pm_timer_address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk, FADT71->gpe0blk_len, FADT71->gpe0blk, gpe0address_space);
+ ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk, FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space);
+
+#else
+
+ /* ACPI 1.0 FACS */
+
+
+ /* The BIOS stored FADT should agree with Revision 1.0 */
+
+ FADT1 = (FADT_DESCRIPTOR_REV1*) acpi_gbl_FADT;
+
+ /*
+ * Copy the table header and the common part of the tables
+ * The 2.0 table is an extension of the 1.0 table, so the
+ * entire 1.0 table can be copied first, then expand some
+ * fields to 64 bits.
+ */
+
+ MEMCPY (FADT2, FADT1, sizeof (FADT_DESCRIPTOR_REV1));
+
+
+ /* Convert table pointers to 64-bit fields */
+
+ FADT2->Xfirmware_ctrl = (UINT64) FADT1->firmware_ctrl;
+ FADT2->Xdsdt = (UINT64) FADT1->dsdt;
+
+ /* System Interrupt Model isn't used in ACPI 2.0*/
+ /* FADT2->Reserved1 = 0; */
+
+ /* This field is set by the OEM to convey the preferred */
+ /* power management profile to OSPM. It doesn't have any*/
+ /* 1.0 equivalence. Since we don't know what kind of */
+ /* 32-bit system this is, we will pick unspecified. */
+
+ FADT2->prefer_PM_profile = PM_UNSPECIFIED;
+
+
+ /* Processor Performance State Control. This is the value */
+ /* OSPM writes to the SMI_CMD register to assume processor */
+ /* performance state control responsibility. There isn't */
+ /* any equivalence in 1.0. So leave it zeroed. */
+
+ FADT2->pstate_cnt = 0;
+
+
+ /* Support for the _CST object and C States change notification.*/
+ /* This data item hasn't any 1.0 equivalence so leaving it zero.*/
+
+ FADT2->cst_cnt = 0;
+
+
+ /* Since there isn't any equivalence in 1.0 and since it */
+ /* is highly likely that a 1.0 system has legacy support. */
+
+ FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES;
+
+
+ /*
+ * Convert the V1.0 Block addresses to V2.0 GAS structures
+ * in this order:
+ *
+ * PM 1_a Events
+ * PM 1_b Events
+ * PM 1_a Control
+ * PM 1_b Control
+ * PM 2 Control
+ * PM Timer Control
+ * GPE Block 0
+ * GPE Block 1
+ */
+
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len, FADT1->pm_tmr_blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk, FADT1->gpe0blk_len, FADT1->gpe0blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk, FADT1->gpe1_blk_len, FADT1->gpe1_blk);
+#endif
+ }
+
+
+ /*
+ * Global FADT pointer will point to the common V2.0 FADT
+ */
+ acpi_gbl_FADT = FADT2;
+
+
+ /* Free the original table */
+
+ table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT];
+ acpi_tb_delete_single_table (table_desc);
+
+
+ /* Install the new table */
+
+ table_desc->pointer = (ACPI_TABLE_HEADER *) acpi_gbl_FADT;
+ table_desc->base_pointer = acpi_gbl_FADT;
+ table_desc->allocation = ACPI_MEM_ALLOCATED;
+ table_desc->length = sizeof (FADT_DESCRIPTOR_REV2);
+
+
+ /* Dump the FADT Header */
+
+ /* Dump the entire FADT */
+
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_convert_table_facs
+ *
+ * PARAMETERS:
+ *
+ * RETURN:
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_tb_build_common_facs (
+ ACPI_TABLE_DESC *table_info)
+{
+ ACPI_COMMON_FACS *common_facs;
+
+#ifdef _IA64
+ FACS_DESCRIPTOR_REV071 *FACS71;
+#else
+ FACS_DESCRIPTOR_REV1 *FACS1;
+#endif
+
+ FACS_DESCRIPTOR_REV2 *FACS2;
+
+
+ /* Allocate a common FACS */
+
+ common_facs = acpi_cm_callocate (sizeof (ACPI_COMMON_FACS));
+ if (!common_facs) {
+ return (AE_NO_MEMORY);
+ }
+
+
+ /* Copy fields to the new FACS */
+
+ if (acpi_gbl_RSDP->revision < 2) {
+#ifdef _IA64
+ /* 0.71 FACS */
+
+ FACS71 = (FACS_DESCRIPTOR_REV071 *) acpi_gbl_FACS;
+
+ common_facs->global_lock = (u32 *) &(FACS71->global_lock);
+ common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector;
+ common_facs->vector_width = 64;
+#else
+ /* ACPI 1.0 FACS */
+
+ FACS1 = (FACS_DESCRIPTOR_REV1 *) acpi_gbl_FACS;
+
+ common_facs->global_lock = &(FACS1->global_lock);
+ common_facs->firmware_waking_vector = (UINT64 *) &FACS1->firmware_waking_vector;
+ common_facs->vector_width = 32;
+
+#endif
+ }
+
+ else {
+ /* ACPI 2.0 FACS */
+
+ FACS2 = (FACS_DESCRIPTOR_REV2 *) acpi_gbl_FACS;
+
+ common_facs->global_lock = &(FACS2->global_lock);
+ common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector;
+ common_facs->vector_width = 64;
+ }
+
+
+ /* Set the global FACS pointer to point to the common FACS */
+
+
+ acpi_gbl_FACS = common_facs;
+
+ return (AE_OK);
+}
+
+
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 19a8f0a2a..2cf8eede7 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: tbget - ACPI Table get* routines
- * $Revision: 22 $
+ * $Revision: 40 $
*
*****************************************************************************/
@@ -32,6 +32,7 @@
#define _COMPONENT TABLE_MANAGER
MODULE_NAME ("tbget")
+#define RSDP_CHECKSUM_LENGTH 20
/*******************************************************************************
*
@@ -127,7 +128,7 @@ acpi_tb_get_table_ptr (
ACPI_STATUS
acpi_tb_get_table (
- void *physical_address,
+ ACPI_PHYSICAL_ADDRESS physical_address,
ACPI_TABLE_HEADER *buffer_ptr,
ACPI_TABLE_DESC *table_info)
{
@@ -239,9 +240,10 @@ acpi_tb_get_all_tables (
MEMSET (&table_info, 0, sizeof (ACPI_TABLE_DESC));
- /* Get the table via the RSDT */
+ /* Get the table via the XSDT */
- status = acpi_tb_get_table ((void *) acpi_gbl_RSDT->table_offset_entry[index],
+ status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS)
+ acpi_gbl_XSDT->table_offset_entry[index],
table_ptr, &table_info);
/* Ignore a table that failed verification */
@@ -266,15 +268,25 @@ acpi_tb_get_all_tables (
* determine if there are enough tables to continue.
*/
- acpi_tb_delete_single_table (&table_info);
+ 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 (status);
+ }
+
+
+ /*
* Get the minimum set of ACPI tables, namely:
*
- * 1) FACP (via RSDT in loop above)
+ * 1) FADT (via RSDT in loop above)
* 2) FACS
* 3) DSDT
*
@@ -282,8 +294,8 @@ acpi_tb_get_all_tables (
/*
- * Get the FACS (must have the FACP first, from loop above)
- * Acpi_tb_get_table_facs will fail if FACP pointer is not valid
+ * 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);
@@ -291,6 +303,7 @@ acpi_tb_get_all_tables (
return (status);
}
+
/* Install the FACS */
status = acpi_tb_install_table (table_ptr, &table_info);
@@ -298,10 +311,22 @@ acpi_tb_get_all_tables (
return (status);
}
+ /*
+ * Create the common FACS pointer table
+ * (Contains pointers to the original table)
+ */
- /* Get the DSDT (We know that the FACP if valid now) */
+ status = acpi_tb_build_common_facs (&table_info);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+
+ /*
+ * Get the DSDT (We know that the FADT is valid now)
+ */
- status = acpi_tb_get_table ((void *) acpi_gbl_FACP->dsdt, table_ptr, &table_info);
+ status = acpi_tb_get_table (acpi_gbl_FADT->Xdsdt, table_ptr, &table_info);
if (ACPI_FAILURE (status)) {
return (status);
}
@@ -321,9 +346,265 @@ acpi_tb_get_all_tables (
* 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);
+
+ return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_verify_rsdp
+ *
+ * PARAMETERS: Number_of_tables - Where the table count is placed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_tb_verify_rsdp (
+ ACPI_PHYSICAL_ADDRESS rsdp_physical_address)
+{
+ ACPI_TABLE_DESC table_info;
+ ACPI_STATUS status;
+ u8 *table_ptr;
+
+
+ /*
+ * Obtain access to the RSDP structure
+ */
+ status = acpi_os_map_memory (rsdp_physical_address,
+ sizeof (RSDP_DESCRIPTOR),
+ (void **) &table_ptr);
+ if (ACPI_FAILURE (status)) {
+ return (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 */
+
+ status = AE_BAD_SIGNATURE;
+ goto cleanup;
+ }
+
+ if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) {
+ /* Nope, BAD Checksum */
+
+ status = AE_BAD_CHECKSUM;
+ goto cleanup;
+ }
+
+ /* 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 */
+
+ status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info);
+ if (ACPI_FAILURE (status)) {
+ goto cleanup;
+ }
+
+
+ /* Save the RSDP in a global for easy access */
+
+ acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer;
+ return (status);
+
+
+ /* Error exit */
+cleanup:
+
+ acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR));
+ return (status);
+}
+
+
+/*******************************************************************************
+ *
+ * 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)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_tb_get_table_rsdt (
+ u32 *number_of_tables)
+{
+ ACPI_TABLE_DESC table_info;
+ ACPI_STATUS status = AE_OK;
+ ACPI_PHYSICAL_ADDRESS physical_address;
+ u32 signature_length;
+ char *table_signature;
+
+
+ /*
+ * Get the RSDT from the RSDP
+ */
+
+ /*
+ * 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_gbl_RSDP->rsdt_physical_address;
+#endif
+ table_signature = RSDT_SIG;
+ signature_length = sizeof (RSDT_SIG) -1;
+ }
+ else {
+ physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->xsdt_physical_address;
+ table_signature = XSDT_SIG;
+ signature_length = sizeof (XSDT_SIG) -1;
+ }
+
+
+ /* Get the RSDT/XSDT */
+
+ status = acpi_tb_get_table (physical_address, NULL, &table_info);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+
+ /* Check the RSDT or XSDT signature */
+
+ if (STRNCMP ((char *) table_info.pointer, table_signature,
+ signature_length))
+ {
+ /* Invalid RSDT or XSDT signature */
+
+ REPORT_ERROR (("Invalid signature where RSDP indicates %s should be located\n",
+ table_signature));
+
+ return (status);
+ }
+
+
+ /* Valid RSDT signature, verify the checksum */
+
+ status = acpi_tb_verify_table_checksum (table_info.pointer);
+
+
+ /* Convert and/or copy to an XSDT structure */
+
+ status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ /* Save the table pointers and allocation info */
+
+ status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info);
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ acpi_gbl_XSDT = (XSDT_DESCRIPTOR *) table_info.pointer;
+
+ return (status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_get_table_facs
+ *
+ * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from
+ * buffer rather than searching memory
+ * *Table_info - Where the table info is returned
+ *
+ * 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.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+acpi_tb_get_table_facs (
+ ACPI_TABLE_HEADER *buffer_ptr,
+ ACPI_TABLE_DESC *table_info)
+{
+ void *table_ptr = NULL;
+ u32 size;
+ u8 allocation;
+ ACPI_STATUS status = AE_OK;
+
+
+ /* Must have a valid FADT pointer */
+
+ if (!acpi_gbl_FADT) {
+ return (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_cm_allocate (size);
+ if(!table_ptr) {
+ return (AE_NO_MEMORY);
+ }
+
+ MEMCPY (table_ptr, buffer_ptr, size);
+
+ /* Save allocation type */
+
+ allocation = ACPI_MEM_ALLOCATED;
+ }
+
+ else {
+ /* Just map the physical memory to our address space */
+
+ status = acpi_tb_map_acpi_table (acpi_gbl_FADT->Xfirmware_ctrl,
+ &size, &table_ptr);
+ if (ACPI_FAILURE(status)) {
+ return (status);
+ }
+
+ /* Save allocation type */
+
+ allocation = ACPI_MEM_MAPPED;
+ }
+
+
+ /* Return values */
+
+ table_info->pointer = table_ptr;
+ table_info->length = size;
+ table_info->allocation = allocation;
+ table_info->base_pointer = table_ptr;
+
return (status);
}
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 56e211ecf..b3926a0e3 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: tbinstal - ACPI table installation and removal
- * $Revision: 29 $
+ * $Revision: 34 $
*
*****************************************************************************/
@@ -307,7 +307,7 @@ acpi_tb_delete_acpi_tables (void)
* Memory can either be mapped or allocated
*/
- for (type = 0; type < ACPI_TABLE_MAX; type++) {
+ for (type = 0; type < NUM_ACPI_TABLES; type++) {
acpi_tb_delete_acpi_table (type);
}
@@ -352,35 +352,24 @@ acpi_tb_delete_acpi_table (
acpi_gbl_RSDP = NULL;
break;
- case ACPI_TABLE_APIC:
- acpi_gbl_APIC = NULL;
- break;
-
case ACPI_TABLE_DSDT:
acpi_gbl_DSDT = NULL;
break;
- case ACPI_TABLE_FACP:
- acpi_gbl_FACP = NULL;
+ case ACPI_TABLE_FADT:
+ acpi_gbl_FADT = NULL;
break;
case ACPI_TABLE_FACS:
acpi_gbl_FACS = NULL;
break;
- case ACPI_TABLE_PSDT:
- break;
-
- case ACPI_TABLE_RSDT:
- acpi_gbl_RSDT = NULL;
+ case ACPI_TABLE_XSDT:
+ acpi_gbl_XSDT = NULL;
break;
case ACPI_TABLE_SSDT:
- break;
-
- case ACPI_TABLE_SBST:
- acpi_gbl_SBST = NULL;
-
+ case ACPI_TABLE_PSDT:
default:
break;
}
@@ -424,7 +413,7 @@ acpi_tb_free_acpi_tables_of_type (
*/
for (i = 0; i < count; i++) {
- table_desc = acpi_tb_delete_single_table (table_desc);
+ table_desc = acpi_tb_uninstall_table (table_desc);
}
return;
@@ -439,37 +428,20 @@ acpi_tb_free_acpi_tables_of_type (
*
* RETURN: None.
*
- * DESCRIPTION: Free the memory associated with an internal ACPI table that
- * is either installed or has never been installed.
- * Table mutex should be locked.
+ * DESCRIPTION: Low-level free for a single ACPI table. Handles cases where
+ * the table was allocated a buffer or was mapped.
*
******************************************************************************/
-ACPI_TABLE_DESC *
+void
acpi_tb_delete_single_table (
ACPI_TABLE_DESC *table_desc)
{
- ACPI_TABLE_DESC *next_desc;
-
if (!table_desc) {
- return (NULL);
- }
-
-
- /* Unlink the descriptor */
-
- if (table_desc->prev) {
- table_desc->prev->next = table_desc->next;
- }
-
- if (table_desc->next) {
- table_desc->next->prev = table_desc->prev;
+ return;
}
-
- /* Free the memory allocated for the table itself */
-
if (table_desc->pointer) {
/* Valid table, determine type of memory allocation */
@@ -477,7 +449,6 @@ acpi_tb_delete_single_table (
{
case ACPI_MEM_NOT_ALLOCATED:
-
break;
@@ -493,10 +464,52 @@ acpi_tb_delete_single_table (
break;
}
}
+}
- /* Free the table descriptor (Don't delete the list head, tho) */
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_uninstall_table
+ *
+ * PARAMETERS: Table_info - A table info struct
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Free the memory associated with an internal ACPI table that
+ * is either installed or has never been installed.
+ * Table mutex should be locked.
+ *
+ ******************************************************************************/
+ACPI_TABLE_DESC *
+acpi_tb_uninstall_table (
+ ACPI_TABLE_DESC *table_desc)
+{
+ ACPI_TABLE_DESC *next_desc;
+
+
+ if (!table_desc) {
+ return (NULL);
+ }
+
+
+ /* Unlink the descriptor */
+
+ if (table_desc->prev) {
+ table_desc->prev->next = table_desc->next;
+ }
+
+ if (table_desc->next) {
+ table_desc->next->prev = table_desc->prev;
+ }
+
+
+ /* Free the memory allocated for the table itself */
+
+ acpi_tb_delete_single_table (table_desc);
+
+
+ /* Free the table descriptor (Don't delete the list head, tho) */
if ((table_desc->prev) == (table_desc->next)) {
diff --git a/drivers/acpi/tables/tbtable.c b/drivers/acpi/tables/tbtable.c
deleted file mode 100644
index fe006bf2e..000000000
--- a/drivers/acpi/tables/tbtable.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/******************************************************************************
- *
- * Module Name: tbtable - ACPI tables: FACP, FACS, and RSDP utilities
- * $Revision: 24 $
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 R. Byron Moore
- *
- * 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
- */
-
-
-#include "acpi.h"
-#include "achware.h"
-#include "actables.h"
-
-
-#define _COMPONENT TABLE_MANAGER
- MODULE_NAME ("tbtable")
-
-
-/*******************************************************************************
- *
- * 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)
- *
- ******************************************************************************/
-
-ACPI_STATUS
-acpi_tb_get_table_rsdt (
- u32 *number_of_tables)
-{
- ACPI_STATUS status = AE_OK;
- ACPI_TABLE_DESC table_info;
-
-
- /* Get the RSDP */
-
- status = acpi_tb_find_rsdp (&table_info);
- if (ACPI_FAILURE (status)) {
- REPORT_WARNING ("RSDP structure not found");
- return (AE_NO_ACPI_TABLES);
- }
-
- /* Save the table pointers and allocation info */
-
- status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info);
- if (ACPI_FAILURE (status)) {
- return (status);
- }
-
- acpi_gbl_RSDP = (ROOT_SYSTEM_DESCRIPTOR_POINTER *) table_info.pointer;
-
-
- /*
- * RSDP structure was found; Now get the RSDT
- */
-
- status = acpi_tb_get_table ((void *) acpi_gbl_RSDP->rsdt_physical_address, NULL,
- &table_info);
- if (ACPI_FAILURE (status)) {
- if (status == AE_BAD_SIGNATURE) {
- /* Invalid RSDT signature */
-
- REPORT_ERROR ("Invalid signature where RSDP indicates RSDT should be located");
-
- }
- REPORT_ERROR ("Unable to locate RSDT");
-
- return (status);
- }
-
-
- /* Always delete the RSDP mapping */
-
- acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP);
-
- /* Save the table pointers and allocation info */
-
- status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDT, &table_info);
- if (ACPI_FAILURE (status)) {
- return (status);
- }
-
- acpi_gbl_RSDT = (ROOT_SYSTEM_DESCRIPTION_TABLE *) table_info.pointer;
-
-
- /* Valid RSDT signature, verify the checksum */
-
- status = acpi_tb_verify_table_checksum ((ACPI_TABLE_HEADER *) acpi_gbl_RSDT);
-
- /*
- * Determine the number of tables pointed to by the RSDT.
- * This is defined by the ACPI Specification to be the number of
- * pointers contained within the RSDT. The size of the pointers
- * is architecture-dependent.
- */
-
- *number_of_tables = ((acpi_gbl_RSDT->header.length -
- sizeof (ACPI_TABLE_HEADER)) / sizeof (void *));
-
-
- return (status);
-}
-
-
-/*******************************************************************************
- *
- * 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
- *
- ******************************************************************************/
-
-u8 *
-acpi_tb_scan_memory_for_rsdp (
- u8 *start_address,
- u32 length)
-{
- u32 offset;
- u8 *mem_rover;
-
-
- /* Search from given start addr for the requested length */
-
- for (offset = 0, mem_rover = start_address;
- offset < length;
- offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP)
- {
-
- /* The signature and checksum must both be correct */
-
- if (STRNCMP ((NATIVE_CHAR *) mem_rover, RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
- acpi_tb_checksum (mem_rover,
- sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) == 0)
- {
- /* If so, we have found the RSDP */
-
- return (mem_rover);
- }
- }
-
- /* Searched entire block, no RSDP was found */
-
- return (NULL);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: Acpi_tb_find_rsdp
- *
- * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer
- * rather than searching memory
- * *Table_info - Where the table info is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
- * pointer structure. If it is found, set *RSDP to point to it.
- *
- * NOTE: The RSDP must be either in the first 1_k of the Extended
- * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
- * 5.2.2; assertion #421).
- *
- ******************************************************************************/
-
-ACPI_STATUS
-acpi_tb_find_rsdp (
- ACPI_TABLE_DESC *table_info)
-{
- u8 *table_ptr;
- u8 *mem_rover;
- ACPI_STATUS status = AE_OK;
-
- if (acpi_gbl_acpi_init_data.RSDP_physical_address) {
- /*
- * RSDP address was supplied as part of the initialization data
- */
-
- status = acpi_os_map_memory(acpi_gbl_acpi_init_data.RSDP_physical_address,
- sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER),
- (void **)&table_ptr);
-
- if (ACPI_FAILURE (status)) {
- return (status);
- }
-
- if (!table_ptr) {
- return (AE_NO_MEMORY);
- }
-
- /*
- * The signature and checksum must both be correct
- */
-
- if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
- /* Nope, BAD Signature */
- acpi_os_unmap_memory (table_ptr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER));
- return (AE_BAD_SIGNATURE);
- }
-
- /* The signature and checksum must both be correct */
-
- if (acpi_tb_checksum (table_ptr,
- sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) != 0)
- {
- /* Nope, BAD Checksum */
- acpi_os_unmap_memory (table_ptr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER));
- return (AE_BAD_CHECKSUM);
- }
-
- /* RSDP supplied is OK */
- /* If so, we have found the RSDP */
-
- table_info->pointer = (ACPI_TABLE_HEADER *) table_ptr;
- table_info->length = sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER);
- table_info->allocation = ACPI_MEM_MAPPED;
- table_info->base_pointer = table_ptr;
-
- return (AE_OK);
- }
-
- /*
- * Search memory for RSDP. First map low physical memory.
- */
-
- status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
- (void **)&table_ptr);
-
- if (ACPI_FAILURE (status)) {
- return (status);
- }
-
- /*
- * 1) Search EBDA (low memory) paragraphs
- */
-
- if (NULL != (mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr,
- LO_RSDP_WINDOW_SIZE)))
- {
- /* Found it, return pointer and don't delete the mapping */
-
- table_info->pointer = (ACPI_TABLE_HEADER *) mem_rover;
- table_info->length = LO_RSDP_WINDOW_SIZE;
- table_info->allocation = ACPI_MEM_MAPPED;
- table_info->base_pointer = table_ptr;
-
- return (AE_OK);
- }
-
- /* This mapping is no longer needed */
-
- acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
-
-
- /*
- * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
- */
-
- status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
- (void **)&table_ptr);
-
- if (ACPI_FAILURE (status)) {
- return (status);
- }
-
- if (NULL != (mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr,
- HI_RSDP_WINDOW_SIZE)))
- {
- /* Found it, return pointer and don't delete the mapping */
-
- table_info->pointer = (ACPI_TABLE_HEADER *) mem_rover;
- table_info->length = HI_RSDP_WINDOW_SIZE;
- table_info->allocation = ACPI_MEM_MAPPED;
- table_info->base_pointer = table_ptr;
-
- return (AE_OK);
- }
-
- /* This mapping is no longer needed */
-
- acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
-
-
- /* RSDP signature was not found */
-
- return (AE_NOT_FOUND);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: Acpi_tb_get_table_facs
- *
- * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from
- * buffer rather than searching memory
- * *Table_info - Where the table info is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Returns a pointer to the FACS as defined in FACP. This
- * function assumes the global variable FACP has been
- * correctly initialized. The value of FACP->Firmware_ctrl
- * into a far pointer which is returned.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-acpi_tb_get_table_facs (
- ACPI_TABLE_HEADER *buffer_ptr,
- ACPI_TABLE_DESC *table_info)
-{
- void *table_ptr = NULL;
- u32 size;
- u8 allocation;
- ACPI_STATUS status = AE_OK;
-
-
- /* Must have a valid FACP pointer */
-
- if (!acpi_gbl_FACP) {
- return (AE_NO_ACPI_TABLES);
- }
-
- size = sizeof (FIRMWARE_ACPI_CONTROL_STRUCTURE);
- if (buffer_ptr) {
- /*
- * Getting table from a file -- allocate a buffer and
- * read the table.
- */
- table_ptr = acpi_cm_allocate (size);
- if(!table_ptr) {
- return (AE_NO_MEMORY);
- }
-
- MEMCPY (table_ptr, buffer_ptr, size);
-
- /* Save allocation type */
-
- allocation = ACPI_MEM_ALLOCATED;
- }
-
- else {
- /* Just map the physical memory to our address space */
-
- status = acpi_tb_map_acpi_table ((void *) acpi_gbl_FACP->firmware_ctrl,
- &size, &table_ptr);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- /* Save allocation type */
-
- allocation = ACPI_MEM_MAPPED;
- }
-
-
- /* Return values */
-
- table_info->pointer = table_ptr;
- table_info->length = size;
- table_info->allocation = allocation;
- table_info->base_pointer = table_ptr;
-
- return (status);
-}
-
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 2a6b7da4b..baae6fb4c 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: tbutils - Table manipulation utilities
- * $Revision: 26 $
+ * $Revision: 31 $
*
*****************************************************************************/
@@ -107,7 +107,9 @@ acpi_tb_system_table_pointer (
/* Check for a pointer within the DSDT */
- if (IS_IN_ACPI_TABLE (where, acpi_gbl_DSDT)) {
+ if ((acpi_gbl_DSDT) &&
+ (IS_IN_ACPI_TABLE (where, acpi_gbl_DSDT)))
+ {
return (TRUE);
}
@@ -186,7 +188,7 @@ acpi_tb_validate_table_header (
MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature);
if (!acpi_cm_valid_acpi_name (signature)) {
- REPORT_WARNING ("Invalid table signature found");
+ REPORT_WARNING (("Invalid table signature found\n"));
return (AE_BAD_SIGNATURE);
}
@@ -194,7 +196,7 @@ acpi_tb_validate_table_header (
/* Validate the table length */
if (table_header->length < sizeof (ACPI_TABLE_HEADER)) {
- REPORT_WARNING ("Invalid table header length found");
+ REPORT_WARNING (("Invalid table header length found\n"));
return (AE_BAD_HEADER);
}
@@ -220,7 +222,7 @@ acpi_tb_validate_table_header (
ACPI_STATUS
acpi_tb_map_acpi_table (
- void *physical_address,
+ ACPI_PHYSICAL_ADDRESS physical_address,
u32 *size,
void **logical_address)
{
@@ -294,18 +296,20 @@ ACPI_STATUS
acpi_tb_verify_table_checksum (
ACPI_TABLE_HEADER *table_header)
{
- u8 check_sum;
+ u8 checksum;
ACPI_STATUS status = AE_OK;
/* Compute the checksum on the table */
- check_sum = acpi_tb_checksum (table_header, table_header->length);
+ checksum = acpi_tb_checksum (table_header, table_header->length);
/* Return the appropriate exception */
- if (check_sum) {
- REPORT_ERROR ("Invalid ACPI table checksum");
+ if (checksum) {
+ REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n",
+ checksum, &table_header->signature));
+
status = AE_BAD_CHECKSUM;
}
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index e1946e572..ee9eba62a 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -2,7 +2,7 @@
*
* Module Name: tbxface - Public interfaces to the ACPI subsystem
* ACPI table oriented interfaces
- * $Revision: 24 $
+ * $Revision: 32 $
*
*****************************************************************************/
@@ -37,43 +37,69 @@
/*******************************************************************************
*
- * FUNCTION: Acpi_load_firmware_tables
+ * FUNCTION: Acpi_load_tables
*
* PARAMETERS: None
*
* RETURN: Status
*
- * DESCRIPTION: This function is called to load the ACPI tables from BIOS
+ * DESCRIPTION: This function is called to load the ACPI tables from the
+ * provided RSDT
*
******************************************************************************/
ACPI_STATUS
-acpi_load_firmware_tables (void)
+acpi_load_tables (
+ ACPI_PHYSICAL_ADDRESS rsdp_physical_address)
{
ACPI_STATUS status = AE_OK;
u32 number_of_tables = 0;
- /* Get the RSDT first */
+ /* Map and validate the RSDP */
- status = acpi_tb_get_table_rsdt (&number_of_tables);
+ status = acpi_tb_verify_rsdp (rsdp_physical_address);
if (ACPI_FAILURE (status)) {
+ REPORT_ERROR (("Acpi_load_tables: RSDP Failed validation: %s\n",
+ acpi_cm_format_exception (status)));
goto error_exit;
}
+ /* Get the RSDT via the RSDP */
+
+ status = acpi_tb_get_table_rsdt (&number_of_tables);
+ if (ACPI_FAILURE (status)) {
+ REPORT_ERROR (("Acpi_load_tables: Could not load RSDT: %s\n",
+ acpi_cm_format_exception (status)));
+ goto error_exit;
+ }
/* Now get the rest of the tables */
status = acpi_tb_get_all_tables (number_of_tables, NULL);
if (ACPI_FAILURE (status)) {
+ REPORT_ERROR (("Acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
+ acpi_cm_format_exception (status)));
goto error_exit;
}
+ /* Load the namespace from the tables */
+
+ status = acpi_ns_load_namespace ();
+ if (ACPI_FAILURE (status)) {
+ REPORT_ERROR (("Acpi_load_tables: Could not load namespace: %s\n",
+ acpi_cm_format_exception (status)));
+ goto error_exit;
+ }
+
return (AE_OK);
error_exit:
+ REPORT_ERROR (("Acpi_load_tables: Could not load tables: %s\n",
+ acpi_cm_format_exception (status)));
+
return (status);
}
@@ -110,7 +136,7 @@ acpi_load_table (
/* Copy the table to a local buffer */
- status = acpi_tb_get_table (NULL, table_ptr, &table_info);
+ status = acpi_tb_get_table (0, table_ptr, &table_info);
if (ACPI_FAILURE (status)) {
return (status);
}
@@ -119,9 +145,22 @@ acpi_load_table (
status = acpi_tb_install_table (NULL, &table_info);
if (ACPI_FAILURE (status)) {
- /* TBD: [Errors] must free table allocated by Acpi_tb_get_table */
+ /* Free table allocated by Acpi_tb_get_table */
+
+ acpi_tb_delete_single_table (&table_info);
+ return (status);
+ }
+
+
+ status = acpi_ns_load_table (table_info.installed_desc, acpi_gbl_root_node);
+ if (ACPI_FAILURE (status)) {
+ /* Uninstall table and free the buffer */
+
+ acpi_tb_uninstall_table (table_info.installed_desc);
+ return (status);
}
+
return (status);
}
@@ -289,12 +328,11 @@ acpi_get_table (
/*
- * Must have a buffer
+ * If we have a buffer, we must have a length too
*/
if ((instance == 0) ||
(!ret_buffer) ||
- (!ret_buffer->pointer) ||
- (!ret_buffer->length))
+ ((!ret_buffer->pointer) && (ret_buffer->length)))
{
return (AE_BAD_PARAMETER);
}
@@ -331,7 +369,7 @@ acpi_get_table (
/*
* RSD PTR is the only "table" without a header
*/
- ret_buf_len = sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER);
+ ret_buf_len = sizeof (RSDP_DESCRIPTOR);
}
else {
ret_buf_len = tbl_ptr->length;
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
new file mode 100644
index 000000000..4c31f1c37
--- /dev/null
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -0,0 +1,214 @@
+/******************************************************************************
+ *
+ * Module Name: tbxfroot - Find the root ACPI table (RSDT)
+ * $Revision: 33 $
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 R. Byron Moore
+ *
+ * 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
+ */
+
+
+#include "acpi.h"
+#include "achware.h"
+#include "actables.h"
+
+
+#define _COMPONENT TABLE_MANAGER
+ MODULE_NAME ("tbxfroot")
+
+#define RSDP_CHECKSUM_LENGTH 20
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_find_root_pointer
+ *
+ * PARAMETERS: **Rsdp_physical_address - Where to place the RSDP address
+ *
+ * RETURN: Status, Physical address of the RSDP
+ *
+ * DESCRIPTION: Find the RSDP
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_find_root_pointer (
+ ACPI_PHYSICAL_ADDRESS *rsdp_physical_address)
+{
+ ACPI_TABLE_DESC table_info;
+ ACPI_STATUS status;
+
+
+ /* Get the RSDP */
+
+ status = acpi_tb_find_rsdp (&table_info);
+ if (ACPI_FAILURE (status)) {
+ return (AE_NO_ACPI_TABLES);
+ }
+
+ *rsdp_physical_address = table_info.physical_address;
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * 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
+ *
+ ******************************************************************************/
+
+u8 *
+acpi_tb_scan_memory_for_rsdp (
+ u8 *start_address,
+ u32 length)
+{
+ u32 offset;
+ u8 *mem_rover;
+
+
+ /* Search from given start addr for the requested length */
+
+ for (offset = 0, mem_rover = start_address;
+ offset < length;
+ offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP)
+ {
+
+ /* The signature and checksum must both be correct */
+
+ if (STRNCMP ((NATIVE_CHAR *) mem_rover,
+ RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
+ acpi_tb_checksum (mem_rover, RSDP_CHECKSUM_LENGTH) == 0)
+ {
+ /* If so, we have found the RSDP */
+
+ return (mem_rover);
+ }
+ }
+
+ /* Searched entire block, no RSDP was found */
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Acpi_tb_find_rsdp
+ *
+ * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer
+ * rather than searching memory
+ * *Table_info - Where the table info is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
+ * pointer structure. If it is found, set *RSDP to point to it.
+ *
+ * NOTE: The RSDP must be either in the first 1_k of the Extended
+ * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
+ * 5.2.2; assertion #421).
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+acpi_tb_find_rsdp (
+ ACPI_TABLE_DESC *table_info)
+{
+ u8 *table_ptr;
+ u8 *mem_rover;
+ UINT64 phys_addr;
+ ACPI_STATUS status = AE_OK;
+
+
+ /*
+ * Search memory for RSDP. First map low physical memory.
+ */
+
+ status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
+ (void **)&table_ptr);
+
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ /*
+ * 1) Search EBDA (low memory) paragraphs
+ */
+
+ mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE);
+
+ /* This mapping is no longer needed */
+
+ acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
+
+ if (mem_rover) {
+ /* Found it, return the physical address */
+
+ phys_addr = LO_RSDP_WINDOW_BASE;
+ phys_addr += (mem_rover - table_ptr);
+
+ table_info->physical_address = phys_addr;
+
+ return (AE_OK);
+ }
+
+
+ /*
+ * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
+ */
+
+ status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
+ (void **)&table_ptr);
+
+ if (ACPI_FAILURE (status)) {
+ return (status);
+ }
+
+ mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE);
+
+ /* This mapping is no longer needed */
+
+ acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
+
+ if (mem_rover) {
+ /* Found it, return the physical address */
+
+ phys_addr = HI_RSDP_WINDOW_BASE;
+ phys_addr += (mem_rover - table_ptr);
+
+ table_info->physical_address = phys_addr;
+
+ return (AE_OK);
+ }
+
+
+ /* RSDP signature was not found */
+
+ return (AE_NOT_FOUND);
+}
+
+