195b482a8SLen Brown /****************************************************************************** 295b482a8SLen Brown * 395b482a8SLen Brown * Module Name: tbinstal - ACPI table installation and removal 495b482a8SLen Brown * 595b482a8SLen Brown *****************************************************************************/ 695b482a8SLen Brown 795b482a8SLen Brown /* 895b482a8SLen Brown * Copyright (C) 2000 - 2008, Intel Corp. 995b482a8SLen Brown * All rights reserved. 1095b482a8SLen Brown * 1195b482a8SLen Brown * Redistribution and use in source and binary forms, with or without 1295b482a8SLen Brown * modification, are permitted provided that the following conditions 1395b482a8SLen Brown * are met: 1495b482a8SLen Brown * 1. Redistributions of source code must retain the above copyright 1595b482a8SLen Brown * notice, this list of conditions, and the following disclaimer, 1695b482a8SLen Brown * without modification. 1795b482a8SLen Brown * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1895b482a8SLen Brown * substantially similar to the "NO WARRANTY" disclaimer below 1995b482a8SLen Brown * ("Disclaimer") and any redistribution must be conditioned upon 2095b482a8SLen Brown * including a substantially similar Disclaimer requirement for further 2195b482a8SLen Brown * binary redistribution. 2295b482a8SLen Brown * 3. Neither the names of the above-listed copyright holders nor the names 2395b482a8SLen Brown * of any contributors may be used to endorse or promote products derived 2495b482a8SLen Brown * from this software without specific prior written permission. 2595b482a8SLen Brown * 2695b482a8SLen Brown * Alternatively, this software may be distributed under the terms of the 2795b482a8SLen Brown * GNU General Public License ("GPL") version 2 as published by the Free 2895b482a8SLen Brown * Software Foundation. 2995b482a8SLen Brown * 3095b482a8SLen Brown * NO WARRANTY 3195b482a8SLen Brown * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3295b482a8SLen Brown * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3395b482a8SLen Brown * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3495b482a8SLen Brown * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3595b482a8SLen Brown * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3695b482a8SLen Brown * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3795b482a8SLen Brown * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3895b482a8SLen Brown * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3995b482a8SLen Brown * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4095b482a8SLen Brown * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4195b482a8SLen Brown * POSSIBILITY OF SUCH DAMAGES. 4295b482a8SLen Brown */ 4395b482a8SLen Brown 4495b482a8SLen Brown #include <acpi/acpi.h> 45*e2f7a777SLen Brown #include "accommon.h" 46*e2f7a777SLen Brown #include "acnamesp.h" 47*e2f7a777SLen Brown #include "actables.h" 4895b482a8SLen Brown 4995b482a8SLen Brown #define _COMPONENT ACPI_TABLES 5095b482a8SLen Brown ACPI_MODULE_NAME("tbinstal") 5195b482a8SLen Brown 5295b482a8SLen Brown /****************************************************************************** 5395b482a8SLen Brown * 5495b482a8SLen Brown * FUNCTION: acpi_tb_verify_table 5595b482a8SLen Brown * 5695b482a8SLen Brown * PARAMETERS: table_desc - table 5795b482a8SLen Brown * 5895b482a8SLen Brown * RETURN: Status 5995b482a8SLen Brown * 6095b482a8SLen Brown * DESCRIPTION: this function is called to verify and map table 6195b482a8SLen Brown * 6295b482a8SLen Brown *****************************************************************************/ 6395b482a8SLen Brown acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) 6495b482a8SLen Brown { 6595b482a8SLen Brown acpi_status status = AE_OK; 6695b482a8SLen Brown 6795b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_verify_table); 6895b482a8SLen Brown 6995b482a8SLen Brown /* Map the table if necessary */ 7095b482a8SLen Brown 7195b482a8SLen Brown if (!table_desc->pointer) { 7295b482a8SLen Brown if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == 7395b482a8SLen Brown ACPI_TABLE_ORIGIN_MAPPED) { 7495b482a8SLen Brown table_desc->pointer = 7595b482a8SLen Brown acpi_os_map_memory(table_desc->address, 7695b482a8SLen Brown table_desc->length); 7795b482a8SLen Brown } 7895b482a8SLen Brown if (!table_desc->pointer) { 7995b482a8SLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 8095b482a8SLen Brown } 8195b482a8SLen Brown } 8295b482a8SLen Brown 8395b482a8SLen Brown /* FACS is the odd table, has no standard ACPI header and no checksum */ 8495b482a8SLen Brown 8595b482a8SLen Brown if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) { 8695b482a8SLen Brown 8795b482a8SLen Brown /* Always calculate checksum, ignore bad checksum if requested */ 8895b482a8SLen Brown 8995b482a8SLen Brown status = 9095b482a8SLen Brown acpi_tb_verify_checksum(table_desc->pointer, 9195b482a8SLen Brown table_desc->length); 9295b482a8SLen Brown } 9395b482a8SLen Brown 9495b482a8SLen Brown return_ACPI_STATUS(status); 9595b482a8SLen Brown } 9695b482a8SLen Brown 9795b482a8SLen Brown /******************************************************************************* 9895b482a8SLen Brown * 9995b482a8SLen Brown * FUNCTION: acpi_tb_add_table 10095b482a8SLen Brown * 10195b482a8SLen Brown * PARAMETERS: table_desc - Table descriptor 10295b482a8SLen Brown * table_index - Where the table index is returned 10395b482a8SLen Brown * 10495b482a8SLen Brown * RETURN: Status 10595b482a8SLen Brown * 10695b482a8SLen Brown * DESCRIPTION: This function is called to add the ACPI table 10795b482a8SLen Brown * 10895b482a8SLen Brown ******************************************************************************/ 10995b482a8SLen Brown 11095b482a8SLen Brown acpi_status 11195b482a8SLen Brown acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) 11295b482a8SLen Brown { 11395b482a8SLen Brown u32 i; 11495b482a8SLen Brown acpi_status status = AE_OK; 11595b482a8SLen Brown 11695b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_add_table); 11795b482a8SLen Brown 11895b482a8SLen Brown if (!table_desc->pointer) { 11995b482a8SLen Brown status = acpi_tb_verify_table(table_desc); 12095b482a8SLen Brown if (ACPI_FAILURE(status) || !table_desc->pointer) { 12195b482a8SLen Brown return_ACPI_STATUS(status); 12295b482a8SLen Brown } 12395b482a8SLen Brown } 12495b482a8SLen Brown 12595b482a8SLen Brown /* 12695b482a8SLen Brown * Originally, we checked the table signature for "SSDT" or "PSDT" here. 12795b482a8SLen Brown * Next, we added support for OEMx tables, signature "OEM". 12895b482a8SLen Brown * Valid tables were encountered with a null signature, so we've just 12995b482a8SLen Brown * given up on validating the signature, since it seems to be a waste 13095b482a8SLen Brown * of code. The original code was removed (05/2008). 13195b482a8SLen Brown */ 13295b482a8SLen Brown 13395b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 13495b482a8SLen Brown 13595b482a8SLen Brown /* Check if table is already registered */ 13695b482a8SLen Brown 13795b482a8SLen Brown for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { 13895b482a8SLen Brown if (!acpi_gbl_root_table_list.tables[i].pointer) { 13995b482a8SLen Brown status = 14095b482a8SLen Brown acpi_tb_verify_table(&acpi_gbl_root_table_list. 14195b482a8SLen Brown tables[i]); 14295b482a8SLen Brown if (ACPI_FAILURE(status) 14395b482a8SLen Brown || !acpi_gbl_root_table_list.tables[i].pointer) { 14495b482a8SLen Brown continue; 14595b482a8SLen Brown } 14695b482a8SLen Brown } 14795b482a8SLen Brown 14895b482a8SLen Brown /* 14995b482a8SLen Brown * Check for a table match on the entire table length, 15095b482a8SLen Brown * not just the header. 15195b482a8SLen Brown */ 15295b482a8SLen Brown if (table_desc->length != 15395b482a8SLen Brown acpi_gbl_root_table_list.tables[i].length) { 15495b482a8SLen Brown continue; 15595b482a8SLen Brown } 15695b482a8SLen Brown 15795b482a8SLen Brown if (ACPI_MEMCMP(table_desc->pointer, 15895b482a8SLen Brown acpi_gbl_root_table_list.tables[i].pointer, 15995b482a8SLen Brown acpi_gbl_root_table_list.tables[i].length)) { 16095b482a8SLen Brown continue; 16195b482a8SLen Brown } 16295b482a8SLen Brown 16395b482a8SLen Brown /* 16495b482a8SLen Brown * Note: the current mechanism does not unregister a table if it is 16595b482a8SLen Brown * dynamically unloaded. The related namespace entries are deleted, 16695b482a8SLen Brown * but the table remains in the root table list. 16795b482a8SLen Brown * 16895b482a8SLen Brown * The assumption here is that the number of different tables that 16995b482a8SLen Brown * will be loaded is actually small, and there is minimal overhead 17095b482a8SLen Brown * in just keeping the table in case it is needed again. 17195b482a8SLen Brown * 17295b482a8SLen Brown * If this assumption changes in the future (perhaps on large 17395b482a8SLen Brown * machines with many table load/unload operations), tables will 17495b482a8SLen Brown * need to be unregistered when they are unloaded, and slots in the 17595b482a8SLen Brown * root table list should be reused when empty. 17695b482a8SLen Brown */ 17795b482a8SLen Brown 17895b482a8SLen Brown /* 17995b482a8SLen Brown * Table is already registered. 18095b482a8SLen Brown * We can delete the table that was passed as a parameter. 18195b482a8SLen Brown */ 18295b482a8SLen Brown acpi_tb_delete_table(table_desc); 18395b482a8SLen Brown *table_index = i; 18495b482a8SLen Brown 18595b482a8SLen Brown if (acpi_gbl_root_table_list.tables[i]. 18695b482a8SLen Brown flags & ACPI_TABLE_IS_LOADED) { 18795b482a8SLen Brown 18895b482a8SLen Brown /* Table is still loaded, this is an error */ 18995b482a8SLen Brown 19095b482a8SLen Brown status = AE_ALREADY_EXISTS; 19195b482a8SLen Brown goto release; 19295b482a8SLen Brown } else { 19395b482a8SLen Brown /* Table was unloaded, allow it to be reloaded */ 19495b482a8SLen Brown 19595b482a8SLen Brown table_desc->pointer = 19695b482a8SLen Brown acpi_gbl_root_table_list.tables[i].pointer; 19795b482a8SLen Brown table_desc->address = 19895b482a8SLen Brown acpi_gbl_root_table_list.tables[i].address; 19995b482a8SLen Brown status = AE_OK; 20095b482a8SLen Brown goto print_header; 20195b482a8SLen Brown } 20295b482a8SLen Brown } 20395b482a8SLen Brown 20495b482a8SLen Brown /* Add the table to the global root table list */ 20595b482a8SLen Brown 20695b482a8SLen Brown status = acpi_tb_store_table(table_desc->address, table_desc->pointer, 20795b482a8SLen Brown table_desc->length, table_desc->flags, 20895b482a8SLen Brown table_index); 20995b482a8SLen Brown if (ACPI_FAILURE(status)) { 21095b482a8SLen Brown goto release; 21195b482a8SLen Brown } 21295b482a8SLen Brown 21395b482a8SLen Brown print_header: 21495b482a8SLen Brown acpi_tb_print_table_header(table_desc->address, table_desc->pointer); 21595b482a8SLen Brown 21695b482a8SLen Brown release: 21795b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 21895b482a8SLen Brown return_ACPI_STATUS(status); 21995b482a8SLen Brown } 22095b482a8SLen Brown 22195b482a8SLen Brown /******************************************************************************* 22295b482a8SLen Brown * 22395b482a8SLen Brown * FUNCTION: acpi_tb_resize_root_table_list 22495b482a8SLen Brown * 22595b482a8SLen Brown * PARAMETERS: None 22695b482a8SLen Brown * 22795b482a8SLen Brown * RETURN: Status 22895b482a8SLen Brown * 22995b482a8SLen Brown * DESCRIPTION: Expand the size of global table array 23095b482a8SLen Brown * 23195b482a8SLen Brown ******************************************************************************/ 23295b482a8SLen Brown 23395b482a8SLen Brown acpi_status acpi_tb_resize_root_table_list(void) 23495b482a8SLen Brown { 23595b482a8SLen Brown struct acpi_table_desc *tables; 23695b482a8SLen Brown 23795b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_resize_root_table_list); 23895b482a8SLen Brown 23995b482a8SLen Brown /* allow_resize flag is a parameter to acpi_initialize_tables */ 24095b482a8SLen Brown 24195b482a8SLen Brown if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { 24295b482a8SLen Brown ACPI_ERROR((AE_INFO, 24395b482a8SLen Brown "Resize of Root Table Array is not allowed")); 24495b482a8SLen Brown return_ACPI_STATUS(AE_SUPPORT); 24595b482a8SLen Brown } 24695b482a8SLen Brown 24795b482a8SLen Brown /* Increase the Table Array size */ 24895b482a8SLen Brown 24995b482a8SLen Brown tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. 25095b482a8SLen Brown size + ACPI_ROOT_TABLE_SIZE_INCREMENT) 25195b482a8SLen Brown * sizeof(struct acpi_table_desc)); 25295b482a8SLen Brown if (!tables) { 25395b482a8SLen Brown ACPI_ERROR((AE_INFO, 25495b482a8SLen Brown "Could not allocate new root table array")); 25595b482a8SLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 25695b482a8SLen Brown } 25795b482a8SLen Brown 25895b482a8SLen Brown /* Copy and free the previous table array */ 25995b482a8SLen Brown 26095b482a8SLen Brown if (acpi_gbl_root_table_list.tables) { 26195b482a8SLen Brown ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, 26295b482a8SLen Brown (acpi_size) acpi_gbl_root_table_list.size * 26395b482a8SLen Brown sizeof(struct acpi_table_desc)); 26495b482a8SLen Brown 26595b482a8SLen Brown if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 26695b482a8SLen Brown ACPI_FREE(acpi_gbl_root_table_list.tables); 26795b482a8SLen Brown } 26895b482a8SLen Brown } 26995b482a8SLen Brown 27095b482a8SLen Brown acpi_gbl_root_table_list.tables = tables; 27195b482a8SLen Brown acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT; 27295b482a8SLen Brown acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED; 27395b482a8SLen Brown 27495b482a8SLen Brown return_ACPI_STATUS(AE_OK); 27595b482a8SLen Brown } 27695b482a8SLen Brown 27795b482a8SLen Brown /******************************************************************************* 27895b482a8SLen Brown * 27995b482a8SLen Brown * FUNCTION: acpi_tb_store_table 28095b482a8SLen Brown * 28195b482a8SLen Brown * PARAMETERS: Address - Table address 28295b482a8SLen Brown * Table - Table header 28395b482a8SLen Brown * Length - Table length 28495b482a8SLen Brown * Flags - flags 28595b482a8SLen Brown * 28695b482a8SLen Brown * RETURN: Status and table index. 28795b482a8SLen Brown * 28895b482a8SLen Brown * DESCRIPTION: Add an ACPI table to the global table list 28995b482a8SLen Brown * 29095b482a8SLen Brown ******************************************************************************/ 29195b482a8SLen Brown 29295b482a8SLen Brown acpi_status 29395b482a8SLen Brown acpi_tb_store_table(acpi_physical_address address, 29495b482a8SLen Brown struct acpi_table_header *table, 29595b482a8SLen Brown u32 length, u8 flags, u32 *table_index) 29695b482a8SLen Brown { 29795b482a8SLen Brown acpi_status status = AE_OK; 29895b482a8SLen Brown 29995b482a8SLen Brown /* Ensure that there is room for the table in the Root Table List */ 30095b482a8SLen Brown 30195b482a8SLen Brown if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) { 30295b482a8SLen Brown status = acpi_tb_resize_root_table_list(); 30395b482a8SLen Brown if (ACPI_FAILURE(status)) { 30495b482a8SLen Brown return (status); 30595b482a8SLen Brown } 30695b482a8SLen Brown } 30795b482a8SLen Brown 30895b482a8SLen Brown /* Initialize added table */ 30995b482a8SLen Brown 31095b482a8SLen Brown acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. 31195b482a8SLen Brown address = address; 31295b482a8SLen Brown acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. 31395b482a8SLen Brown pointer = table; 31495b482a8SLen Brown acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length = 31595b482a8SLen Brown length; 31695b482a8SLen Brown acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. 31795b482a8SLen Brown owner_id = 0; 31895b482a8SLen Brown acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags = 31995b482a8SLen Brown flags; 32095b482a8SLen Brown 32195b482a8SLen Brown ACPI_MOVE_32_TO_32(& 32295b482a8SLen Brown (acpi_gbl_root_table_list. 32395b482a8SLen Brown tables[acpi_gbl_root_table_list.count].signature), 32495b482a8SLen Brown table->signature); 32595b482a8SLen Brown 32695b482a8SLen Brown *table_index = acpi_gbl_root_table_list.count; 32795b482a8SLen Brown acpi_gbl_root_table_list.count++; 32895b482a8SLen Brown return (status); 32995b482a8SLen Brown } 33095b482a8SLen Brown 33195b482a8SLen Brown /******************************************************************************* 33295b482a8SLen Brown * 33395b482a8SLen Brown * FUNCTION: acpi_tb_delete_table 33495b482a8SLen Brown * 33595b482a8SLen Brown * PARAMETERS: table_index - Table index 33695b482a8SLen Brown * 33795b482a8SLen Brown * RETURN: None 33895b482a8SLen Brown * 33995b482a8SLen Brown * DESCRIPTION: Delete one internal ACPI table 34095b482a8SLen Brown * 34195b482a8SLen Brown ******************************************************************************/ 34295b482a8SLen Brown 34395b482a8SLen Brown void acpi_tb_delete_table(struct acpi_table_desc *table_desc) 34495b482a8SLen Brown { 34595b482a8SLen Brown /* Table must be mapped or allocated */ 34695b482a8SLen Brown if (!table_desc->pointer) { 34795b482a8SLen Brown return; 34895b482a8SLen Brown } 34995b482a8SLen Brown switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { 35095b482a8SLen Brown case ACPI_TABLE_ORIGIN_MAPPED: 35195b482a8SLen Brown acpi_os_unmap_memory(table_desc->pointer, table_desc->length); 35295b482a8SLen Brown break; 35395b482a8SLen Brown case ACPI_TABLE_ORIGIN_ALLOCATED: 35495b482a8SLen Brown ACPI_FREE(table_desc->pointer); 35595b482a8SLen Brown break; 35695b482a8SLen Brown default:; 35795b482a8SLen Brown } 35895b482a8SLen Brown 35995b482a8SLen Brown table_desc->pointer = NULL; 36095b482a8SLen Brown } 36195b482a8SLen Brown 36295b482a8SLen Brown /******************************************************************************* 36395b482a8SLen Brown * 36495b482a8SLen Brown * FUNCTION: acpi_tb_terminate 36595b482a8SLen Brown * 36695b482a8SLen Brown * PARAMETERS: None 36795b482a8SLen Brown * 36895b482a8SLen Brown * RETURN: None 36995b482a8SLen Brown * 37095b482a8SLen Brown * DESCRIPTION: Delete all internal ACPI tables 37195b482a8SLen Brown * 37295b482a8SLen Brown ******************************************************************************/ 37395b482a8SLen Brown 37495b482a8SLen Brown void acpi_tb_terminate(void) 37595b482a8SLen Brown { 37695b482a8SLen Brown u32 i; 37795b482a8SLen Brown 37895b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_terminate); 37995b482a8SLen Brown 38095b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 38195b482a8SLen Brown 38295b482a8SLen Brown /* Delete the individual tables */ 38395b482a8SLen Brown 38495b482a8SLen Brown for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { 38595b482a8SLen Brown acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]); 38695b482a8SLen Brown } 38795b482a8SLen Brown 38895b482a8SLen Brown /* 38995b482a8SLen Brown * Delete the root table array if allocated locally. Array cannot be 39095b482a8SLen Brown * mapped, so we don't need to check for that flag. 39195b482a8SLen Brown */ 39295b482a8SLen Brown if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { 39395b482a8SLen Brown ACPI_FREE(acpi_gbl_root_table_list.tables); 39495b482a8SLen Brown } 39595b482a8SLen Brown 39695b482a8SLen Brown acpi_gbl_root_table_list.tables = NULL; 39795b482a8SLen Brown acpi_gbl_root_table_list.flags = 0; 39895b482a8SLen Brown acpi_gbl_root_table_list.count = 0; 39995b482a8SLen Brown 40095b482a8SLen Brown ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); 40195b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 40295b482a8SLen Brown } 40395b482a8SLen Brown 40495b482a8SLen Brown /******************************************************************************* 40595b482a8SLen Brown * 40695b482a8SLen Brown * FUNCTION: acpi_tb_delete_namespace_by_owner 40795b482a8SLen Brown * 40895b482a8SLen Brown * PARAMETERS: table_index - Table index 40995b482a8SLen Brown * 41095b482a8SLen Brown * RETURN: None 41195b482a8SLen Brown * 41295b482a8SLen Brown * DESCRIPTION: Delete all namespace objects created when this table was loaded. 41395b482a8SLen Brown * 41495b482a8SLen Brown ******************************************************************************/ 41595b482a8SLen Brown 41695b482a8SLen Brown void acpi_tb_delete_namespace_by_owner(u32 table_index) 41795b482a8SLen Brown { 41895b482a8SLen Brown acpi_owner_id owner_id; 41995b482a8SLen Brown 42095b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 42195b482a8SLen Brown if (table_index < acpi_gbl_root_table_list.count) { 42295b482a8SLen Brown owner_id = 42395b482a8SLen Brown acpi_gbl_root_table_list.tables[table_index].owner_id; 42495b482a8SLen Brown } else { 42595b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 42695b482a8SLen Brown return; 42795b482a8SLen Brown } 42895b482a8SLen Brown 42995b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 43095b482a8SLen Brown acpi_ns_delete_namespace_by_owner(owner_id); 43195b482a8SLen Brown } 43295b482a8SLen Brown 43395b482a8SLen Brown /******************************************************************************* 43495b482a8SLen Brown * 43595b482a8SLen Brown * FUNCTION: acpi_tb_allocate_owner_id 43695b482a8SLen Brown * 43795b482a8SLen Brown * PARAMETERS: table_index - Table index 43895b482a8SLen Brown * 43995b482a8SLen Brown * RETURN: Status 44095b482a8SLen Brown * 44195b482a8SLen Brown * DESCRIPTION: Allocates owner_id in table_desc 44295b482a8SLen Brown * 44395b482a8SLen Brown ******************************************************************************/ 44495b482a8SLen Brown 44595b482a8SLen Brown acpi_status acpi_tb_allocate_owner_id(u32 table_index) 44695b482a8SLen Brown { 44795b482a8SLen Brown acpi_status status = AE_BAD_PARAMETER; 44895b482a8SLen Brown 44995b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_allocate_owner_id); 45095b482a8SLen Brown 45195b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 45295b482a8SLen Brown if (table_index < acpi_gbl_root_table_list.count) { 45395b482a8SLen Brown status = acpi_ut_allocate_owner_id 45495b482a8SLen Brown (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); 45595b482a8SLen Brown } 45695b482a8SLen Brown 45795b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 45895b482a8SLen Brown return_ACPI_STATUS(status); 45995b482a8SLen Brown } 46095b482a8SLen Brown 46195b482a8SLen Brown /******************************************************************************* 46295b482a8SLen Brown * 46395b482a8SLen Brown * FUNCTION: acpi_tb_release_owner_id 46495b482a8SLen Brown * 46595b482a8SLen Brown * PARAMETERS: table_index - Table index 46695b482a8SLen Brown * 46795b482a8SLen Brown * RETURN: Status 46895b482a8SLen Brown * 46995b482a8SLen Brown * DESCRIPTION: Releases owner_id in table_desc 47095b482a8SLen Brown * 47195b482a8SLen Brown ******************************************************************************/ 47295b482a8SLen Brown 47395b482a8SLen Brown acpi_status acpi_tb_release_owner_id(u32 table_index) 47495b482a8SLen Brown { 47595b482a8SLen Brown acpi_status status = AE_BAD_PARAMETER; 47695b482a8SLen Brown 47795b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_release_owner_id); 47895b482a8SLen Brown 47995b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 48095b482a8SLen Brown if (table_index < acpi_gbl_root_table_list.count) { 48195b482a8SLen Brown acpi_ut_release_owner_id(& 48295b482a8SLen Brown (acpi_gbl_root_table_list. 48395b482a8SLen Brown tables[table_index].owner_id)); 48495b482a8SLen Brown status = AE_OK; 48595b482a8SLen Brown } 48695b482a8SLen Brown 48795b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 48895b482a8SLen Brown return_ACPI_STATUS(status); 48995b482a8SLen Brown } 49095b482a8SLen Brown 49195b482a8SLen Brown /******************************************************************************* 49295b482a8SLen Brown * 49395b482a8SLen Brown * FUNCTION: acpi_tb_get_owner_id 49495b482a8SLen Brown * 49595b482a8SLen Brown * PARAMETERS: table_index - Table index 49695b482a8SLen Brown * owner_id - Where the table owner_id is returned 49795b482a8SLen Brown * 49895b482a8SLen Brown * RETURN: Status 49995b482a8SLen Brown * 50095b482a8SLen Brown * DESCRIPTION: returns owner_id for the ACPI table 50195b482a8SLen Brown * 50295b482a8SLen Brown ******************************************************************************/ 50395b482a8SLen Brown 50495b482a8SLen Brown acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id) 50595b482a8SLen Brown { 50695b482a8SLen Brown acpi_status status = AE_BAD_PARAMETER; 50795b482a8SLen Brown 50895b482a8SLen Brown ACPI_FUNCTION_TRACE(tb_get_owner_id); 50995b482a8SLen Brown 51095b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 51195b482a8SLen Brown if (table_index < acpi_gbl_root_table_list.count) { 51295b482a8SLen Brown *owner_id = 51395b482a8SLen Brown acpi_gbl_root_table_list.tables[table_index].owner_id; 51495b482a8SLen Brown status = AE_OK; 51595b482a8SLen Brown } 51695b482a8SLen Brown 51795b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 51895b482a8SLen Brown return_ACPI_STATUS(status); 51995b482a8SLen Brown } 52095b482a8SLen Brown 52195b482a8SLen Brown /******************************************************************************* 52295b482a8SLen Brown * 52395b482a8SLen Brown * FUNCTION: acpi_tb_is_table_loaded 52495b482a8SLen Brown * 52595b482a8SLen Brown * PARAMETERS: table_index - Table index 52695b482a8SLen Brown * 52795b482a8SLen Brown * RETURN: Table Loaded Flag 52895b482a8SLen Brown * 52995b482a8SLen Brown ******************************************************************************/ 53095b482a8SLen Brown 53195b482a8SLen Brown u8 acpi_tb_is_table_loaded(u32 table_index) 53295b482a8SLen Brown { 53395b482a8SLen Brown u8 is_loaded = FALSE; 53495b482a8SLen Brown 53595b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 53695b482a8SLen Brown if (table_index < acpi_gbl_root_table_list.count) { 53795b482a8SLen Brown is_loaded = (u8) 53895b482a8SLen Brown (acpi_gbl_root_table_list.tables[table_index]. 53995b482a8SLen Brown flags & ACPI_TABLE_IS_LOADED); 54095b482a8SLen Brown } 54195b482a8SLen Brown 54295b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 54395b482a8SLen Brown return (is_loaded); 54495b482a8SLen Brown } 54595b482a8SLen Brown 54695b482a8SLen Brown /******************************************************************************* 54795b482a8SLen Brown * 54895b482a8SLen Brown * FUNCTION: acpi_tb_set_table_loaded_flag 54995b482a8SLen Brown * 55095b482a8SLen Brown * PARAMETERS: table_index - Table index 55195b482a8SLen Brown * is_loaded - TRUE if table is loaded, FALSE otherwise 55295b482a8SLen Brown * 55395b482a8SLen Brown * RETURN: None 55495b482a8SLen Brown * 55595b482a8SLen Brown * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. 55695b482a8SLen Brown * 55795b482a8SLen Brown ******************************************************************************/ 55895b482a8SLen Brown 55995b482a8SLen Brown void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) 56095b482a8SLen Brown { 56195b482a8SLen Brown 56295b482a8SLen Brown (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 56395b482a8SLen Brown if (table_index < acpi_gbl_root_table_list.count) { 56495b482a8SLen Brown if (is_loaded) { 56595b482a8SLen Brown acpi_gbl_root_table_list.tables[table_index].flags |= 56695b482a8SLen Brown ACPI_TABLE_IS_LOADED; 56795b482a8SLen Brown } else { 56895b482a8SLen Brown acpi_gbl_root_table_list.tables[table_index].flags &= 56995b482a8SLen Brown ~ACPI_TABLE_IS_LOADED; 57095b482a8SLen Brown } 57195b482a8SLen Brown } 57295b482a8SLen Brown 57395b482a8SLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 57495b482a8SLen Brown } 575