X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Facpi%2Ftables%2Ftbinstal.c;h=1668a232fb6754fb3a0d571cf32cb443863cefa0;hb=refs%2Fheads%2Fvserver;hp=85d5bb01022c1be435e86cf959fe89a8075b479b;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c index 85d5bb010..1668a232f 100644 --- a/drivers/acpi/tables/tbinstal.c +++ b/drivers/acpi/tables/tbinstal.c @@ -5,7 +5,7 @@ *****************************************************************************/ /* - * Copyright (C) 2000 - 2005, R. Byron Moore + * Copyright (C) 2000 - 2006, R. Byron Moore * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,14 +41,16 @@ * POSSIBILITY OF SUCH DAMAGES. */ - #include #include - #define _COMPONENT ACPI_TABLES - ACPI_MODULE_NAME ("tbinstal") +ACPI_MODULE_NAME("tbinstal") +/* Local prototypes */ +static acpi_status +acpi_tb_match_signature(char *signature, + struct acpi_table_desc *table_info, u8 search_type); /******************************************************************************* * @@ -56,6 +58,7 @@ * * PARAMETERS: Signature - Table signature to match * table_info - Return data + * search_type - Table type to match (primary/secondary) * * RETURN: Status * @@ -64,50 +67,46 @@ * ******************************************************************************/ -acpi_status -acpi_tb_match_signature ( - char *signature, - struct acpi_table_desc *table_info, - u8 search_type) +static acpi_status +acpi_tb_match_signature(char *signature, + struct acpi_table_desc *table_info, u8 search_type) { - acpi_native_uint i; + acpi_native_uint i; + ACPI_FUNCTION_TRACE(tb_match_signature); - ACPI_FUNCTION_TRACE ("tb_match_signature"); + /* Search for a signature match among the known table types */ - - /* - * Search for a signature match among the known table types - */ - for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { + for (i = 0; i < (ACPI_TABLE_ID_MAX + 1); i++) { if (!(acpi_gbl_table_data[i].flags & search_type)) { continue; } - if (!ACPI_STRNCMP (signature, acpi_gbl_table_data[i].signature, - acpi_gbl_table_data[i].sig_length)) { + if (!ACPI_STRNCMP(signature, acpi_gbl_table_data[i].signature, + acpi_gbl_table_data[i].sig_length)) { + /* Found a signature match, return index if requested */ if (table_info) { table_info->type = (u8) i; } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", - (char *) acpi_gbl_table_data[i].signature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Table [%4.4s] is an ACPI table consumed by the core subsystem\n", + (char *)acpi_gbl_table_data[i]. + signature)); - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS(AE_OK); } } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", - (char *) signature)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Table [%4.4s] is not an ACPI table consumed by the core subsystem - ignored\n", + (char *)signature)); - return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); + return_ACPI_STATUS(AE_TABLE_NOT_SUPPORTED); } - /******************************************************************************* * * FUNCTION: acpi_tb_install_table @@ -116,51 +115,58 @@ acpi_tb_match_signature ( * * RETURN: Status * - * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must - * already be loaded and validated. - * Install the table into the global data structs. + * DESCRIPTION: Install the table into the global data structures. * ******************************************************************************/ -acpi_status -acpi_tb_install_table ( - struct acpi_table_desc *table_info) +acpi_status acpi_tb_install_table(struct acpi_table_desc *table_info) { - acpi_status status; - - ACPI_FUNCTION_TRACE ("tb_install_table"); + acpi_status status; + ACPI_FUNCTION_TRACE(tb_install_table); /* Lock tables while installing */ - status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n", - table_info->pointer->signature, acpi_format_exception (status))); - return_ACPI_STATUS (status); + status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); + if (ACPI_FAILURE(status)) { + ACPI_EXCEPTION((AE_INFO, status, + "Could not acquire table mutex")); + return_ACPI_STATUS(status); + } + + /* + * Ignore a table that is already installed. For example, some BIOS + * ASL code will repeatedly attempt to load the same SSDT. + */ + status = acpi_tb_is_table_installed(table_info); + if (ACPI_FAILURE(status)) { + goto unlock_and_exit; } /* Install the table into the global data structure */ - status = acpi_tb_init_table_descriptor (table_info->type, table_info); - if (ACPI_FAILURE (status)) { - ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n", - table_info->pointer->signature, acpi_format_exception (status))); + status = acpi_tb_init_table_descriptor(table_info->type, table_info); + if (ACPI_FAILURE(status)) { + ACPI_EXCEPTION((AE_INFO, status, + "Could not install table [%4.4s]", + table_info->pointer->signature)); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", - acpi_gbl_table_data[table_info->type].name, table_info->pointer)); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s located at %p\n", + acpi_gbl_table_data[table_info->type].name, + table_info->pointer)); - (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); - return_ACPI_STATUS (status); + unlock_and_exit: + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_recognize_table * * PARAMETERS: table_info - Return value from acpi_tb_get_table_body + * search_type - Table type to match (primary/secondary) * * RETURN: Status * @@ -177,22 +183,18 @@ acpi_tb_install_table ( ******************************************************************************/ acpi_status -acpi_tb_recognize_table ( - struct acpi_table_desc *table_info, - u8 search_type) +acpi_tb_recognize_table(struct acpi_table_desc *table_info, u8 search_type) { - struct acpi_table_header *table_header; - acpi_status status; - - - ACPI_FUNCTION_TRACE ("tb_recognize_table"); + struct acpi_table_header *table_header; + acpi_status status; + ACPI_FUNCTION_TRACE(tb_recognize_table); /* Ensure that we have a valid table pointer */ - table_header = (struct acpi_table_header *) table_info->pointer; + table_header = (struct acpi_table_header *)table_info->pointer; if (!table_header) { - return_ACPI_STATUS (AE_BAD_PARAMETER); + return_ACPI_STATUS(AE_BAD_PARAMETER); } /* @@ -203,24 +205,23 @@ acpi_tb_recognize_table ( * This can be any one of many valid ACPI tables, it just isn't one of * the tables that is consumed by the core subsystem */ - status = acpi_tb_match_signature (table_header->signature, table_info, search_type); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_match_signature(table_header->signature, + table_info, search_type); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } - status = acpi_tb_validate_table_header (table_header); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); + status = acpi_tb_validate_table_header(table_header); + if (ACPI_FAILURE(status)) { + return_ACPI_STATUS(status); } /* Return the table type and length via the info struct */ table_info->length = (acpi_size) table_header->length; - - return_ACPI_STATUS (status); + return_ACPI_STATUS(status); } - /******************************************************************************* * * FUNCTION: acpi_tb_init_table_descriptor @@ -235,27 +236,31 @@ acpi_tb_recognize_table ( ******************************************************************************/ acpi_status -acpi_tb_init_table_descriptor ( - acpi_table_type table_type, - struct acpi_table_desc *table_info) +acpi_tb_init_table_descriptor(acpi_table_type table_type, + struct acpi_table_desc *table_info) { - struct acpi_table_list *list_head; - struct acpi_table_desc *table_desc; - - - ACPI_FUNCTION_TRACE_U32 ("tb_init_table_descriptor", table_type); + struct acpi_table_list *list_head; + struct acpi_table_desc *table_desc; + acpi_status status; + ACPI_FUNCTION_TRACE_U32(tb_init_table_descriptor, table_type); /* Allocate a descriptor for this table */ - table_desc = ACPI_MEM_CALLOCATE (sizeof (struct acpi_table_desc)); + table_desc = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_table_desc)); if (!table_desc) { - return_ACPI_STATUS (AE_NO_MEMORY); + return_ACPI_STATUS(AE_NO_MEMORY); } - /* - * Install the table into the global data structure - */ + /* Get a new owner ID for the table */ + + status = acpi_ut_allocate_owner_id(&table_desc->owner_id); + if (ACPI_FAILURE(status)) { + goto error_exit1; + } + + /* Install the table into the global data structure */ + list_head = &acpi_gbl_table_lists[table_type]; /* @@ -263,14 +268,14 @@ acpi_tb_init_table_descriptor ( * includes most ACPI tables such as the DSDT. 2) Multiple instances of * the table are allowed. This includes SSDT and PSDTs. */ - if (ACPI_IS_SINGLE_TABLE (acpi_gbl_table_data[table_type].flags)) { + if (ACPI_IS_SINGLE_TABLE(acpi_gbl_table_data[table_type].flags)) { /* * Only one table allowed, and a table has alread been installed * at this location, so return an error. */ if (list_head->next) { - ACPI_MEM_FREE (table_desc); - return_ACPI_STATUS (AE_ALREADY_EXISTS); + status = AE_ALREADY_EXISTS; + goto error_exit2; } table_desc->next = list_head->next; @@ -281,8 +286,7 @@ acpi_tb_init_table_descriptor ( } list_head->count++; - } - else { + } else { /* * Link the new table in to the list of tables of this type. * Insert at the end of the list, order IS IMPORTANT. @@ -293,8 +297,7 @@ acpi_tb_init_table_descriptor ( if (!list_head->next) { list_head->next = table_desc; - } - else { + } else { table_desc->next = list_head->next; while (table_desc->next->next) { @@ -309,32 +312,41 @@ acpi_tb_init_table_descriptor ( /* Finish initialization of the table descriptor */ - table_desc->type = (u8) table_type; - table_desc->pointer = table_info->pointer; - table_desc->length = table_info->length; - table_desc->allocation = table_info->allocation; - table_desc->aml_start = (u8 *) (table_desc->pointer + 1), - table_desc->aml_length = (u32) (table_desc->length - - (u32) sizeof (struct acpi_table_header)); - table_desc->table_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_TABLE); table_desc->loaded_into_namespace = FALSE; + table_desc->type = (u8) table_type; + table_desc->pointer = table_info->pointer; + table_desc->length = table_info->length; + table_desc->allocation = table_info->allocation; + table_desc->aml_start = (u8 *) (table_desc->pointer + 1), + table_desc->aml_length = (u32) + (table_desc->length - (u32) sizeof(struct acpi_table_header)); /* * Set the appropriate global pointer (if there is one) to point to the * newly installed table */ if (acpi_gbl_table_data[table_type].global_ptr) { - *(acpi_gbl_table_data[table_type].global_ptr) = table_info->pointer; + *(acpi_gbl_table_data[table_type].global_ptr) = + table_info->pointer; } /* Return Data */ - table_info->table_id = table_desc->table_id; - table_info->installed_desc = table_desc; + table_info->owner_id = table_desc->owner_id; + table_info->installed_desc = table_desc; + return_ACPI_STATUS(AE_OK); - return_ACPI_STATUS (AE_OK); -} + /* Error exit with cleanup */ + + error_exit2: + + acpi_ut_release_owner_id(&table_desc->owner_id); + error_exit1: + + ACPI_FREE(table_desc); + return_ACPI_STATUS(status); +} /******************************************************************************* * @@ -348,22 +360,19 @@ acpi_tb_init_table_descriptor ( * ******************************************************************************/ -void -acpi_tb_delete_all_tables (void) +void acpi_tb_delete_all_tables(void) { - acpi_table_type type; - + acpi_table_type type; /* * Free memory allocated for ACPI tables * Memory can either be mapped or allocated */ - for (type = 0; type < NUM_ACPI_TABLE_TYPES; type++) { - acpi_tb_delete_tables_by_type (type); + for (type = 0; type < (ACPI_TABLE_ID_MAX + 1); type++) { + acpi_tb_delete_tables_by_type(type); } } - /******************************************************************************* * * FUNCTION: acpi_tb_delete_tables_by_type @@ -377,51 +386,47 @@ acpi_tb_delete_all_tables (void) * ******************************************************************************/ -void -acpi_tb_delete_tables_by_type ( - acpi_table_type type) +void acpi_tb_delete_tables_by_type(acpi_table_type type) { - struct acpi_table_desc *table_desc; - u32 count; - u32 i; - - - ACPI_FUNCTION_TRACE_U32 ("tb_delete_tables_by_type", type); + struct acpi_table_desc *table_desc; + u32 count; + u32 i; + ACPI_FUNCTION_TRACE_U32(tb_delete_tables_by_type, type); - if (type > ACPI_TABLE_MAX) { + if (type > ACPI_TABLE_ID_MAX) { return_VOID; } - if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_TABLES))) { + if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_TABLES))) { return; } /* Clear the appropriate "typed" global table pointer */ switch (type) { - case ACPI_TABLE_RSDP: + case ACPI_TABLE_ID_RSDP: acpi_gbl_RSDP = NULL; break; - case ACPI_TABLE_DSDT: + case ACPI_TABLE_ID_DSDT: acpi_gbl_DSDT = NULL; break; - case ACPI_TABLE_FADT: + case ACPI_TABLE_ID_FADT: acpi_gbl_FADT = NULL; break; - case ACPI_TABLE_FACS: + case ACPI_TABLE_ID_FACS: acpi_gbl_FACS = NULL; break; - case ACPI_TABLE_XSDT: + case ACPI_TABLE_ID_XSDT: acpi_gbl_XSDT = NULL; break; - case ACPI_TABLE_SSDT: - case ACPI_TABLE_PSDT: + case ACPI_TABLE_ID_SSDT: + case ACPI_TABLE_ID_PSDT: default: break; } @@ -431,21 +436,20 @@ acpi_tb_delete_tables_by_type ( * 1) Get the head of the list */ table_desc = acpi_gbl_table_lists[type].next; - count = acpi_gbl_table_lists[type].count; + count = acpi_gbl_table_lists[type].count; /* * 2) Walk the entire list, deleting both the allocated tables * and the table descriptors */ for (i = 0; i < count; i++) { - table_desc = acpi_tb_uninstall_table (table_desc); + table_desc = acpi_tb_uninstall_table(table_desc); } - (void) acpi_ut_release_mutex (ACPI_MTX_TABLES); + (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); return_VOID; } - /******************************************************************************* * * FUNCTION: acpi_tb_delete_single_table @@ -459,15 +463,12 @@ acpi_tb_delete_tables_by_type ( * ******************************************************************************/ -void -acpi_tb_delete_single_table ( - struct acpi_table_desc *table_desc) +void acpi_tb_delete_single_table(struct acpi_table_desc *table_desc) { /* Must have a valid table descriptor and pointer */ - if ((!table_desc) || - (!table_desc->pointer)) { + if ((!table_desc) || (!table_desc->pointer)) { return; } @@ -479,12 +480,12 @@ acpi_tb_delete_single_table ( case ACPI_MEM_ALLOCATED: - ACPI_MEM_FREE (table_desc->pointer); + ACPI_FREE(table_desc->pointer); break; case ACPI_MEM_MAPPED: - acpi_os_unmap_memory (table_desc->pointer, table_desc->length); + acpi_os_unmap_memory(table_desc->pointer, table_desc->length); break; default: @@ -492,7 +493,6 @@ acpi_tb_delete_single_table ( } } - /******************************************************************************* * * FUNCTION: acpi_tb_uninstall_table @@ -507,26 +507,22 @@ acpi_tb_delete_single_table ( * ******************************************************************************/ -struct acpi_table_desc * -acpi_tb_uninstall_table ( - struct acpi_table_desc *table_desc) +struct acpi_table_desc *acpi_tb_uninstall_table(struct acpi_table_desc + *table_desc) { - struct acpi_table_desc *next_desc; - - - ACPI_FUNCTION_TRACE_PTR ("tb_uninstall_table", table_desc); + struct acpi_table_desc *next_desc; + ACPI_FUNCTION_TRACE_PTR(tb_uninstall_table, table_desc); if (!table_desc) { - return_PTR (NULL); + return_PTR(NULL); } /* Unlink the descriptor from the doubly linked list */ if (table_desc->prev) { table_desc->prev->next = table_desc->next; - } - else { + } else { /* Is first on list, update list head */ acpi_gbl_table_lists[table_desc->type].next = table_desc->next; @@ -538,16 +534,18 @@ acpi_tb_uninstall_table ( /* Free the memory allocated for the table itself */ - acpi_tb_delete_single_table (table_desc); + acpi_tb_delete_single_table(table_desc); + + /* Free the owner ID associated with this table */ + + acpi_ut_release_owner_id(&table_desc->owner_id); /* Free the table descriptor */ next_desc = table_desc->next; - ACPI_MEM_FREE (table_desc); + ACPI_FREE(table_desc); /* Return pointer to the next descriptor */ - return_PTR (next_desc); + return_PTR(next_desc); } - -