Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: tbinstal - ACPI table installation and removal |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 45 | #include <acpi/acnamesp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <acpi/actables.h> |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT ACPI_TABLES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("tbinstal") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 51 | /****************************************************************************** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 53 | * FUNCTION: acpi_tb_verify_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 55 | * PARAMETERS: table_desc - table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | * |
| 57 | * RETURN: Status |
| 58 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 59 | * DESCRIPTION: this function is called to verify and map table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 61 | *****************************************************************************/ |
| 62 | acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 64 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 66 | ACPI_FUNCTION_TRACE(tb_verify_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 68 | /* Map the table if necessary */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 69 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 70 | if (!table_desc->pointer) { |
| 71 | table_desc->pointer = |
| 72 | acpi_tb_map(table_desc->address, table_desc->length, |
| 73 | table_desc->flags & ACPI_TABLE_ORIGIN_MASK); |
| 74 | if (!table_desc->pointer) { |
| 75 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 79 | /* FACS is the odd table, has no standard ACPI header and no checksum */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 81 | if (ACPI_COMPARE_NAME(&(table_desc->signature), ACPI_SIG_FACS)) { |
| 82 | return_ACPI_STATUS(AE_OK); |
| 83 | } |
| 84 | |
| 85 | /* Always calculate checksum, ignore bad checksum if requested */ |
| 86 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 87 | status = |
| 88 | acpi_tb_verify_checksum(table_desc->pointer, table_desc->length); |
| 89 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | /******************************************************************************* |
| 93 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 94 | * FUNCTION: acpi_tb_add_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 96 | * PARAMETERS: Table - Pointer to the table header |
| 97 | * table_index - Where the table index is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | * |
| 99 | * RETURN: Status |
| 100 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 101 | * DESCRIPTION: This function is called to add the ACPI table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | * |
| 103 | ******************************************************************************/ |
| 104 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 105 | acpi_status |
| 106 | acpi_tb_add_table(struct acpi_table_header *table, |
| 107 | acpi_native_uint * table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 109 | acpi_native_uint i; |
| 110 | acpi_native_uint length; |
| 111 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 113 | ACPI_FUNCTION_TRACE(tb_add_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 115 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 117 | /* Check if table is already registered */ |
| 118 | |
| 119 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { |
| 120 | if (!acpi_gbl_root_table_list.tables[i].pointer) { |
| 121 | status = |
| 122 | acpi_tb_verify_table(&acpi_gbl_root_table_list. |
| 123 | tables[i]); |
| 124 | if (ACPI_FAILURE(status) |
| 125 | || !acpi_gbl_root_table_list.tables[i].pointer) { |
| 126 | continue; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | length = ACPI_MIN(table->length, |
| 131 | acpi_gbl_root_table_list.tables[i].pointer-> |
| 132 | length); |
| 133 | if (ACPI_MEMCMP |
| 134 | (table, acpi_gbl_root_table_list.tables[i].pointer, |
| 135 | length)) { |
| 136 | continue; |
| 137 | } |
| 138 | |
| 139 | /* Table is already registered */ |
| 140 | |
| 141 | ACPI_FREE(table); |
| 142 | *table_index = i; |
| 143 | goto release; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 146 | /* |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 147 | * Add the table to the global table list |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 148 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 149 | status = acpi_tb_store_table(ACPI_TO_INTEGER(table), |
| 150 | table, table->length, |
| 151 | ACPI_TABLE_ORIGIN_ALLOCATED, table_index); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | if (ACPI_FAILURE(status)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 153 | goto release; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 156 | acpi_tb_print_table_header(0, table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 158 | release: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 159 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 160 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | /******************************************************************************* |
| 164 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 165 | * FUNCTION: acpi_tb_resize_root_table_list |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 167 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | * |
| 169 | * RETURN: Status |
| 170 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 171 | * DESCRIPTION: Expand the size of global table array |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | * |
| 173 | ******************************************************************************/ |
| 174 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 175 | acpi_status acpi_tb_resize_root_table_list(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 177 | struct acpi_table_desc *tables; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 179 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 181 | /* allow_resize flag is a parameter to acpi_initialize_tables */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 183 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 184 | ACPI_ERROR((AE_INFO, |
| 185 | "Resize of Root Table Array is not allowed")); |
| 186 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 189 | /* Increase the Table Array size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 191 | tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size + |
| 192 | ACPI_ROOT_TABLE_SIZE_INCREMENT) |
| 193 | * sizeof(struct acpi_table_desc)); |
| 194 | if (!tables) { |
| 195 | ACPI_ERROR((AE_INFO, |
| 196 | "Could not allocate new root table array")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 197 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 200 | /* Copy and free the previous table array */ |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 201 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 202 | if (acpi_gbl_root_table_list.tables) { |
| 203 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, |
| 204 | acpi_gbl_root_table_list.size * |
| 205 | sizeof(struct acpi_table_desc)); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 206 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 207 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 208 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 212 | acpi_gbl_root_table_list.tables = tables; |
| 213 | acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT; |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 214 | acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 216 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | /******************************************************************************* |
| 220 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 221 | * FUNCTION: acpi_tb_store_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 223 | * PARAMETERS: Address - Table address |
| 224 | * Table - Table header |
| 225 | * Length - Table length |
| 226 | * Flags - flags |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 228 | * RETURN: Status and table index. |
| 229 | * |
| 230 | * DESCRIPTION: Add an ACPI table to the global table list |
| 231 | * |
| 232 | ******************************************************************************/ |
| 233 | |
| 234 | acpi_status |
| 235 | acpi_tb_store_table(acpi_physical_address address, |
| 236 | struct acpi_table_header *table, |
| 237 | u32 length, u8 flags, acpi_native_uint * table_index) |
| 238 | { |
| 239 | acpi_status status = AE_OK; |
| 240 | |
| 241 | /* Ensure that there is room for the table in the Root Table List */ |
| 242 | |
| 243 | if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) { |
| 244 | status = acpi_tb_resize_root_table_list(); |
| 245 | if (ACPI_FAILURE(status)) { |
| 246 | return (status); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /* Initialize added table */ |
| 251 | |
| 252 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. |
| 253 | address = address; |
| 254 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. |
| 255 | pointer = table; |
| 256 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length = |
| 257 | length; |
| 258 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. |
| 259 | owner_id = 0; |
| 260 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags = |
| 261 | flags; |
| 262 | |
| 263 | ACPI_MOVE_32_TO_32(& |
| 264 | (acpi_gbl_root_table_list. |
| 265 | tables[acpi_gbl_root_table_list.count].signature), |
| 266 | table->signature); |
| 267 | |
| 268 | *table_index = acpi_gbl_root_table_list.count; |
| 269 | acpi_gbl_root_table_list.count++; |
| 270 | return (status); |
| 271 | } |
| 272 | |
| 273 | /******************************************************************************* |
| 274 | * |
| 275 | * FUNCTION: acpi_tb_delete_table |
| 276 | * |
| 277 | * PARAMETERS: table_index - Table index |
| 278 | * |
| 279 | * RETURN: None |
| 280 | * |
| 281 | * DESCRIPTION: Delete one internal ACPI table |
| 282 | * |
| 283 | ******************************************************************************/ |
| 284 | |
| 285 | void acpi_tb_delete_table(acpi_native_uint table_index) |
| 286 | { |
| 287 | struct acpi_table_desc *table_desc; |
| 288 | |
| 289 | /* table_index assumed valid */ |
| 290 | |
| 291 | table_desc = &acpi_gbl_root_table_list.tables[table_index]; |
| 292 | |
| 293 | /* Table must be mapped or allocated */ |
| 294 | |
| 295 | if (!table_desc->pointer) { |
| 296 | return; |
| 297 | } |
| 298 | |
| 299 | if (table_desc->flags & ACPI_TABLE_ORIGIN_MAPPED) { |
| 300 | acpi_tb_unmap(table_desc->pointer, table_desc->length, |
| 301 | table_desc->flags & ACPI_TABLE_ORIGIN_MASK); |
| 302 | } else if (table_desc->flags & ACPI_TABLE_ORIGIN_ALLOCATED) { |
| 303 | ACPI_FREE(table_desc->pointer); |
| 304 | } |
| 305 | |
| 306 | table_desc->pointer = NULL; |
| 307 | } |
| 308 | |
| 309 | /******************************************************************************* |
| 310 | * |
| 311 | * FUNCTION: acpi_tb_terminate |
| 312 | * |
| 313 | * PARAMETERS: None |
| 314 | * |
| 315 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | * |
| 317 | * DESCRIPTION: Delete all internal ACPI tables |
| 318 | * |
| 319 | ******************************************************************************/ |
| 320 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 321 | void acpi_tb_terminate(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 323 | acpi_native_uint i; |
| 324 | |
| 325 | ACPI_FUNCTION_TRACE(tb_terminate); |
| 326 | |
| 327 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 328 | |
| 329 | /* Delete the individual tables */ |
| 330 | |
| 331 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { |
| 332 | acpi_tb_delete_table(i); |
| 333 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
| 335 | /* |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 336 | * Delete the root table array if allocated locally. Array cannot be |
| 337 | * mapped, so we don't need to check for that flag. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | */ |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 339 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 340 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 342 | |
| 343 | acpi_gbl_root_table_list.tables = NULL; |
| 344 | acpi_gbl_root_table_list.flags = 0; |
| 345 | acpi_gbl_root_table_list.count = 0; |
| 346 | |
| 347 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); |
| 348 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | /******************************************************************************* |
| 352 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 353 | * FUNCTION: acpi_tb_delete_namespace_by_owner |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 355 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 357 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 359 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | * |
| 361 | ******************************************************************************/ |
| 362 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 363 | void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 365 | acpi_owner_id owner_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 367 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 368 | if (table_index < acpi_gbl_root_table_list.count) { |
| 369 | owner_id = |
| 370 | acpi_gbl_root_table_list.tables[table_index].owner_id; |
| 371 | } else { |
| 372 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | return; |
| 374 | } |
| 375 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 376 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 377 | acpi_ns_delete_namespace_by_owner(owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | /******************************************************************************* |
| 381 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 382 | * FUNCTION: acpi_tb_allocate_owner_id |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 384 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 386 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 388 | * DESCRIPTION: Allocates owner_id in table_desc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | * |
| 390 | ******************************************************************************/ |
| 391 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 392 | acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 394 | acpi_status status = AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 396 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 398 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 399 | if (table_index < acpi_gbl_root_table_list.count) { |
| 400 | status = acpi_ut_allocate_owner_id |
| 401 | (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 404 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 405 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | } |
| 407 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | /******************************************************************************* |
| 409 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 410 | * FUNCTION: acpi_tb_release_owner_id |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 412 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 414 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 416 | * DESCRIPTION: Releases owner_id in table_desc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | * |
| 418 | ******************************************************************************/ |
| 419 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 420 | acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 422 | acpi_status status = AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 424 | ACPI_FUNCTION_TRACE(tb_release_owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 426 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 427 | if (table_index < acpi_gbl_root_table_list.count) { |
| 428 | acpi_ut_release_owner_id(& |
| 429 | (acpi_gbl_root_table_list. |
| 430 | tables[table_index].owner_id)); |
| 431 | status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | } |
| 433 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 434 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 435 | return_ACPI_STATUS(status); |
| 436 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 438 | /******************************************************************************* |
| 439 | * |
| 440 | * FUNCTION: acpi_tb_get_owner_id |
| 441 | * |
| 442 | * PARAMETERS: table_index - Table index |
| 443 | * owner_id - Where the table owner_id is returned |
| 444 | * |
| 445 | * RETURN: Status |
| 446 | * |
| 447 | * DESCRIPTION: returns owner_id for the ACPI table |
| 448 | * |
| 449 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 451 | acpi_status |
| 452 | acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id) |
| 453 | { |
| 454 | acpi_status status = AE_BAD_PARAMETER; |
| 455 | |
| 456 | ACPI_FUNCTION_TRACE(tb_get_owner_id); |
| 457 | |
| 458 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 459 | if (table_index < acpi_gbl_root_table_list.count) { |
| 460 | *owner_id = |
| 461 | acpi_gbl_root_table_list.tables[table_index].owner_id; |
| 462 | status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 465 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 466 | return_ACPI_STATUS(status); |
| 467 | } |
| 468 | |
| 469 | /******************************************************************************* |
| 470 | * |
| 471 | * FUNCTION: acpi_tb_is_table_loaded |
| 472 | * |
| 473 | * PARAMETERS: table_index - Table index |
| 474 | * |
| 475 | * RETURN: Table Loaded Flag |
| 476 | * |
| 477 | ******************************************************************************/ |
| 478 | |
| 479 | u8 acpi_tb_is_table_loaded(acpi_native_uint table_index) |
| 480 | { |
| 481 | u8 is_loaded = FALSE; |
| 482 | |
| 483 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 484 | if (table_index < acpi_gbl_root_table_list.count) { |
| 485 | is_loaded = (u8) |
| 486 | (acpi_gbl_root_table_list.tables[table_index]. |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 487 | flags & ACPI_TABLE_IS_LOADED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 490 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 491 | return (is_loaded); |
| 492 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 494 | /******************************************************************************* |
| 495 | * |
| 496 | * FUNCTION: acpi_tb_set_table_loaded_flag |
| 497 | * |
| 498 | * PARAMETERS: table_index - Table index |
| 499 | * is_loaded - TRUE if table is loaded, FALSE otherwise |
| 500 | * |
| 501 | * RETURN: None |
| 502 | * |
| 503 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. |
| 504 | * |
| 505 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 507 | void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded) |
| 508 | { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 509 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 510 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 511 | if (table_index < acpi_gbl_root_table_list.count) { |
| 512 | if (is_loaded) { |
| 513 | acpi_gbl_root_table_list.tables[table_index].flags |= |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 514 | ACPI_TABLE_IS_LOADED; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 515 | } else { |
| 516 | acpi_gbl_root_table_list.tables[table_index].flags &= |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame^] | 517 | ~ACPI_TABLE_IS_LOADED; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 518 | } |
| 519 | } |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 520 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 521 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | } |