From 012bb3e61e5eced6c610f9e036372bf0c8def2d1 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 5 Oct 2000 01:18:40 +0000 Subject: Merge with Linux 2.4.0-test9. Please check DECstation, I had a number of rejects to fixup while integrating Linus patches. I also found that this kernel will only boot SMP on Origin; the UP kernel freeze soon after bootup with SCSI timeout messages. I commit this anyway since I found that the last CVS versions had the same problem. --- drivers/acpi/tables/Makefile | 28 ++++++++++ drivers/acpi/tables/tbget.c | 31 ++++++----- drivers/acpi/tables/tbinstal.c | 117 +++++++++++++++++++---------------------- drivers/acpi/tables/tbtable.c | 58 ++++++++++---------- drivers/acpi/tables/tbutils.c | 41 ++++++++------- drivers/acpi/tables/tbxface.c | 40 +++++++------- 6 files changed, 173 insertions(+), 142 deletions(-) create mode 100644 drivers/acpi/tables/Makefile (limited to 'drivers/acpi/tables') diff --git a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile new file mode 100644 index 000000000..edd897133 --- /dev/null +++ b/drivers/acpi/tables/Makefile @@ -0,0 +1,28 @@ +# +# 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)) + +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: + $(RM) *.o diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c index 255ca172d..19a8f0a2a 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 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "hardware.h" -#include "tables.h" +#include "achware.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbget"); + MODULE_NAME ("tbget") /******************************************************************************* @@ -90,10 +90,15 @@ acpi_tb_get_table_ptr ( return (AE_NOT_EXIST); } - /* Walk the list to get the table */ - + /* 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 = 1; i < acpi_gbl_acpi_tables[table_type].count; i++) { + for (i = 2; i < instance; i++) { table_desc = table_desc->next; } @@ -110,8 +115,8 @@ acpi_tb_get_table_ptr ( * FUNCTION: Acpi_tb_get_table * * PARAMETERS: Physical_address - Physical address of table to retrieve - * *Buffer_ptr - If == NULL, read data from buffer - * rather than searching memory + * *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 @@ -123,7 +128,7 @@ acpi_tb_get_table_ptr ( ACPI_STATUS acpi_tb_get_table ( void *physical_address, - char *buffer_ptr, + ACPI_TABLE_HEADER *buffer_ptr, ACPI_TABLE_DESC *table_info) { ACPI_TABLE_HEADER *table_header = NULL; @@ -143,7 +148,7 @@ acpi_tb_get_table ( * Getting data from a buffer, not BIOS tables */ - table_header = (ACPI_TABLE_HEADER *) buffer_ptr; + 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 */ @@ -160,7 +165,7 @@ acpi_tb_get_table ( /* Copy the entire table (including header) to the local buffer */ - size = (ACPI_SIZE) table_header->length; + size = table_header->length; MEMCPY (full_table, buffer_ptr, size); /* Save allocation type */ @@ -216,7 +221,7 @@ acpi_tb_get_table ( ACPI_STATUS acpi_tb_get_all_tables ( u32 number_of_tables, - char *table_ptr) + ACPI_TABLE_HEADER *table_ptr) { ACPI_STATUS status = AE_OK; u32 index; diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 54e077f08..56e211ecf 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 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "hardware.h" -#include "tables.h" +#include "achware.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbinstal"); + MODULE_NAME ("tbinstal") /******************************************************************************* @@ -50,11 +50,9 @@ ACPI_STATUS acpi_tb_install_table ( - char *table_ptr, + ACPI_TABLE_HEADER *table_ptr, ACPI_TABLE_DESC *table_info) { - ACPI_TABLE_TYPE table_type; - ACPI_TABLE_HEADER *table_header; ACPI_STATUS status; @@ -68,11 +66,6 @@ acpi_tb_install_table ( return (status); } - /* Table type is returned by Recognize_table */ - - table_type = table_info->type; - table_header = table_info->pointer; - /* Lock tables while installing */ acpi_cm_acquire_mutex (ACPI_MTX_TABLES); @@ -80,12 +73,9 @@ acpi_tb_install_table ( /* Install the table into the global data structure */ status = acpi_tb_init_table_descriptor (table_info->type, table_info); - if (ACPI_FAILURE (status)) { - return (status); - } acpi_cm_release_mutex (ACPI_MTX_TABLES); - return (AE_OK); + return (status); } @@ -112,7 +102,7 @@ acpi_tb_install_table ( ACPI_STATUS acpi_tb_recognize_table ( - char *table_ptr, + ACPI_TABLE_HEADER *table_ptr, ACPI_TABLE_DESC *table_info) { ACPI_TABLE_HEADER *table_header; @@ -215,9 +205,10 @@ acpi_tb_init_table_descriptor ( * the table are allowed. This includes SSDT and PSDTs. */ - if (acpi_gbl_acpi_table_data[table_type].flags == ACPI_TABLE_SINGLE) { + if (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags)) { /* - * Only one table allowed, just update the list head + * Only one table allowed, and a table has alread been installed + * at this location, so return an error. */ if (list_head->pointer) { @@ -249,7 +240,7 @@ acpi_tb_init_table_descriptor ( /* Update new entry */ table_desc->prev = list_head->prev; - table_desc->next = (ACPI_TABLE_DESC *) list_head; + table_desc->next = list_head; /* Update list head */ @@ -308,7 +299,7 @@ acpi_tb_init_table_descriptor ( void acpi_tb_delete_acpi_tables (void) { - u32 i; + ACPI_TABLE_TYPE type; /* @@ -316,8 +307,8 @@ acpi_tb_delete_acpi_tables (void) * Memory can either be mapped or allocated */ - for (i = 0; i < ACPI_TABLE_MAX; i++) { - acpi_tb_delete_acpi_table (i); + for (type = 0; type < ACPI_TABLE_MAX; type++) { + acpi_tb_delete_acpi_table (type); } } @@ -400,6 +391,46 @@ acpi_tb_delete_acpi_table ( } +/******************************************************************************* + * + * FUNCTION: Acpi_tb_free_acpi_tables_of_type + * + * PARAMETERS: Table_info - A table info struct + * + * RETURN: None. + * + * DESCRIPTION: Free the memory associated with an internal ACPI table + * Table mutex should be locked. + * + ******************************************************************************/ + +void +acpi_tb_free_acpi_tables_of_type ( + ACPI_TABLE_DESC *list_head) +{ + ACPI_TABLE_DESC *table_desc; + u32 count; + u32 i; + + + /* Get the head of the list */ + + table_desc = list_head; + count = list_head->count; + + /* + * Walk the entire list, deleting both the allocated tables + * and the table descriptors + */ + + for (i = 0; i < count; i++) { + table_desc = acpi_tb_delete_single_table (table_desc); + } + + return; +} + + /******************************************************************************* * * FUNCTION: Acpi_tb_delete_single_table @@ -491,43 +522,3 @@ acpi_tb_delete_single_table ( } -/******************************************************************************* - * - * FUNCTION: Acpi_tb_free_acpi_tables_of_type - * - * PARAMETERS: Table_info - A table info struct - * - * RETURN: None. - * - * DESCRIPTION: Free the memory associated with an internal ACPI table - * Table mutex should be locked. - * - ******************************************************************************/ - -void -acpi_tb_free_acpi_tables_of_type ( - ACPI_TABLE_DESC *list_head) -{ - ACPI_TABLE_DESC *table_desc; - u32 count; - u32 i; - - - /* Get the head of the list */ - - table_desc = list_head; - count = list_head->count; - - /* - * Walk the entire list, deleting both the allocated tables - * and the table descriptors - */ - - for (i = 0; i < count; i++) { - table_desc = acpi_tb_delete_single_table (table_desc); - } - - return; -} - - diff --git a/drivers/acpi/tables/tbtable.c b/drivers/acpi/tables/tbtable.c index a78a23acf..fe006bf2e 100644 --- a/drivers/acpi/tables/tbtable.c +++ b/drivers/acpi/tables/tbtable.c @@ -1,7 +1,7 @@ - /****************************************************************************** * * Module Name: tbtable - ACPI tables: FACP, FACS, and RSDP utilities + * $Revision: 24 $ * *****************************************************************************/ @@ -25,12 +25,12 @@ #include "acpi.h" -#include "hardware.h" -#include "tables.h" +#include "achware.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbtable"); + MODULE_NAME ("tbtable") /******************************************************************************* @@ -38,7 +38,6 @@ * FUNCTION: Acpi_tb_get_table_rsdt * * PARAMETERS: Number_of_tables - Where the table count is placed - * Table_ptr - Input buffer pointer, optional * * RETURN: Status * @@ -85,15 +84,15 @@ acpi_tb_get_table_rsdt ( 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); - if (ACPI_FAILURE (status)) { - return (status); - } /* Save the table pointers and allocation info */ @@ -109,10 +108,15 @@ acpi_tb_get_table_rsdt ( status = acpi_tb_verify_table_checksum ((ACPI_TABLE_HEADER *) acpi_gbl_RSDT); - /* Determine the number of tables pointed to by the 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 = (s32) DIV_4 (acpi_gbl_RSDT->header.length - - sizeof (ACPI_TABLE_HEADER)); + *number_of_tables = ((acpi_gbl_RSDT->header.length - + sizeof (ACPI_TABLE_HEADER)) / sizeof (void *)); return (status); @@ -132,13 +136,13 @@ acpi_tb_get_table_rsdt ( * ******************************************************************************/ -char * +u8 * acpi_tb_scan_memory_for_rsdp ( - char *start_address, + u8 *start_address, u32 length) { u32 offset; - char *mem_rover; + u8 *mem_rover; /* Search from given start addr for the requested length */ @@ -150,19 +154,19 @@ acpi_tb_scan_memory_for_rsdp ( /* The signature and checksum must both be correct */ - if (STRNCMP (mem_rover, RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && + 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; + return (mem_rover); } } /* Searched entire block, no RSDP was found */ - return NULL; + return (NULL); } @@ -189,8 +193,8 @@ ACPI_STATUS acpi_tb_find_rsdp ( ACPI_TABLE_DESC *table_info) { - char *table_ptr; - char *mem_rover; + u8 *table_ptr; + u8 *mem_rover; ACPI_STATUS status = AE_OK; if (acpi_gbl_acpi_init_data.RSDP_physical_address) { @@ -214,9 +218,9 @@ acpi_tb_find_rsdp ( * The signature and checksum must both be correct */ - if (STRNCMP (table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + 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); } @@ -226,7 +230,7 @@ acpi_tb_find_rsdp ( sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)) != 0) { /* Nope, BAD Checksum */ - + acpi_os_unmap_memory (table_ptr, sizeof (ROOT_SYSTEM_DESCRIPTOR_POINTER)); return (AE_BAD_CHECKSUM); } @@ -309,12 +313,12 @@ acpi_tb_find_rsdp ( } -/******************************************************************************* +/****************************************************************************** * * FUNCTION: Acpi_tb_get_table_facs * - * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer - * rather than searching memory + * 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 @@ -324,11 +328,11 @@ acpi_tb_find_rsdp ( * correctly initialized. The value of FACP->Firmware_ctrl * into a far pointer which is returned. * - ******************************************************************************/ + *****************************************************************************/ ACPI_STATUS acpi_tb_get_table_facs ( - char *buffer_ptr, + ACPI_TABLE_HEADER *buffer_ptr, ACPI_TABLE_DESC *table_info) { void *table_ptr = NULL; diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c index 45519a824..2a6b7da4b 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 $ * *****************************************************************************/ @@ -25,23 +25,24 @@ #include "acpi.h" -#include "tables.h" -#include "interp.h" +#include "actables.h" +#include "acinterp.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbutils"); + MODULE_NAME ("tbutils") /******************************************************************************* * - * FUNCTION: Acpi_tb_system_table_pointer + * FUNCTION: Acpi_tb_handle_to_object * - * PARAMETERS: *Where - Pointer to be examined + * PARAMETERS: Table_id - Id for which the function is searching + * Table_desc - Pointer to return the matching table + * descriptor. * - * RETURN: TRUE if Where is within the AML stream (in one of the ACPI - * system tables such as the DSDT or an SSDT.) - * FALSE otherwise + * RETURN: Search the tables to find one with a matching Table_id and + * return a pointer to that table descriptor. * ******************************************************************************/ @@ -60,7 +61,7 @@ acpi_tb_handle_to_object ( { if (list_head->table_id == table_id) { *table_desc = list_head; - return AE_OK; + return (AE_OK); } list_head = list_head->next; @@ -69,7 +70,7 @@ acpi_tb_handle_to_object ( } - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } @@ -177,7 +178,7 @@ acpi_tb_validate_table_header ( /* Verify that this is a valid address */ if (!acpi_os_readable (table_header, sizeof (ACPI_TABLE_HEADER))) { - return AE_BAD_ADDRESS; + return (AE_BAD_ADDRESS); } @@ -186,7 +187,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"); - return AE_BAD_SIGNATURE; + return (AE_BAD_SIGNATURE); } @@ -194,10 +195,10 @@ acpi_tb_validate_table_header ( if (table_header->length < sizeof (ACPI_TABLE_HEADER)) { REPORT_WARNING ("Invalid table header length found"); - return AE_BAD_HEADER; + return (AE_BAD_HEADER); } - return AE_OK; + return (AE_OK); } @@ -236,7 +237,7 @@ acpi_tb_map_acpi_table ( status = acpi_os_map_memory (physical_address, sizeof (ACPI_TABLE_HEADER), (void **) &table); if (ACPI_FAILURE (status)) { - return status; + return (status); } /* Extract the full table length before we delete the mapping */ @@ -257,7 +258,7 @@ acpi_tb_map_acpi_table ( /* Exit if header invalid */ if (ACPI_FAILURE (status)) { - return status; + return (status); } } @@ -266,13 +267,13 @@ acpi_tb_map_acpi_table ( status = acpi_os_map_memory (physical_address, table_size, (void **) &table); if (ACPI_FAILURE (status)) { - return status; + return (status); } *size = table_size; *logical_address = table; - return status; + return (status); } @@ -346,7 +347,7 @@ acpi_tb_checksum ( } } - return sum; + return (sum); } diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index ba650c114..e1946e572 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c @@ -1,8 +1,8 @@ - /****************************************************************************** * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces + * $Revision: 24 $ * *****************************************************************************/ @@ -26,13 +26,13 @@ #include "acpi.h" -#include "namesp.h" -#include "interp.h" -#include "tables.h" +#include "acnamesp.h" +#include "acinterp.h" +#include "actables.h" #define _COMPONENT TABLE_MANAGER - MODULE_NAME ("tbxface"); + MODULE_NAME ("tbxface") /******************************************************************************* @@ -57,7 +57,7 @@ acpi_load_firmware_tables (void) /* Get the RSDT first */ status = acpi_tb_get_table_rsdt (&number_of_tables); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto error_exit; } @@ -65,7 +65,7 @@ acpi_load_firmware_tables (void) /* Now get the rest of the tables */ status = acpi_tb_get_all_tables (number_of_tables, NULL); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { goto error_exit; } @@ -105,12 +105,12 @@ acpi_load_table ( if (!table_ptr) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } /* Copy the table to a local buffer */ - status = acpi_tb_get_table (NULL, ((char *) table_ptr), &table_info); + status = acpi_tb_get_table (NULL, table_ptr, &table_info); if (ACPI_FAILURE (status)) { return (status); } @@ -157,7 +157,12 @@ acpi_unload_table ( list_head = &acpi_gbl_acpi_tables[table_type]; do { - /* Delete the entire namespace under this table NTE */ + /* + * Delete all namespace entries owned by this table. Note that these + * entries can appear anywhere in the namespace by virtue of the AML + * "Scope" operator. Thus, we need to track ownership by an ID, not + * simply a position within the hierarchy + */ acpi_ns_delete_namespace_by_owner (list_head->table_id); @@ -205,8 +210,6 @@ acpi_get_table_header ( ACPI_STATUS status; - status = AE_OK; - if ((instance == 0) || (table_type == ACPI_TABLE_RSDP) || (!out_table_header)) @@ -217,7 +220,7 @@ acpi_get_table_header ( /* Check the table type and instance */ if ((table_type > ACPI_TABLE_MAX) || - (acpi_gbl_acpi_table_data[table_type].flags == ACPI_TABLE_SINGLE && + (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) && instance > 1)) { return (AE_BAD_PARAMETER); @@ -227,7 +230,7 @@ acpi_get_table_header ( /* Get a pointer to the entire table */ status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } @@ -285,8 +288,6 @@ acpi_get_table ( u32 ret_buf_len; - status = AE_OK; - /* * Must have a buffer */ @@ -301,7 +302,7 @@ acpi_get_table ( /* Check the table type and instance */ if ((table_type > ACPI_TABLE_MAX) || - (acpi_gbl_acpi_table_data[table_type].flags == ACPI_TABLE_SINGLE && + (IS_SINGLE_TABLE (acpi_gbl_acpi_table_data[table_type].flags) && instance > 1)) { return (AE_BAD_PARAMETER); @@ -311,12 +312,13 @@ acpi_get_table ( /* Get a pointer to the entire table */ status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr); - if (status != AE_OK) { + if (ACPI_FAILURE (status)) { return (status); } /* - * The function will return a NULL pointer if the table is not loaded + * Acpi_tb_get_table_ptr will return a NULL pointer if the + * table is not loaded. */ if (tbl_ptr == NULL) { return (AE_NOT_EXIST); -- cgit v1.2.3