blob: 6a6ee1f06c764527849310452b3bff887e84ab97 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: tbinstal - ACPI table installation and removal
4 *
5 *****************************************************************************/
6
7/*
Bob Moore6c9deb72007-02-02 19:48:24 +03008 * Copyright (C) 2000 - 2007, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Bob Mooref3d2e782007-02-02 19:48:18 +030045#include <acpi/acnamesp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <acpi/actables.h>
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_TABLES
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("tbinstal")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Bob Mooref3d2e782007-02-02 19:48:18 +030051/******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 *
Bob Mooref3d2e782007-02-02 19:48:18 +030053 * FUNCTION: acpi_tb_verify_table
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 *
Bob Mooref3d2e782007-02-02 19:48:18 +030055 * PARAMETERS: table_desc - table
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 *
57 * RETURN: Status
58 *
Bob Mooref3d2e782007-02-02 19:48:18 +030059 * DESCRIPTION: this function is called to verify and map table
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 *
Bob Mooref3d2e782007-02-02 19:48:18 +030061 *****************************************************************************/
62acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Alexey Starikovskiy428f2112007-02-02 19:48:22 +030064 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Bob Mooref3d2e782007-02-02 19:48:18 +030066 ACPI_FUNCTION_TRACE(tb_verify_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Bob Mooref3d2e782007-02-02 19:48:18 +030068 /* Map the table if necessary */
Robert Moore44f6c012005-04-18 22:49:35 -040069
Bob Mooref3d2e782007-02-02 19:48:18 +030070 if (!table_desc->pointer) {
Alexey Starikovskiy428f2112007-02-02 19:48:22 +030071 if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
72 ACPI_TABLE_ORIGIN_MAPPED) {
73 table_desc->pointer =
74 acpi_os_map_memory(table_desc->address,
75 table_desc->length);
76 }
Bob Mooref3d2e782007-02-02 19:48:18 +030077 if (!table_desc->pointer) {
78 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 }
80 }
81
Bob Mooref3d2e782007-02-02 19:48:18 +030082 /* FACS is the odd table, has no standard ACPI header and no checksum */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Alexey Starikovskiy428f2112007-02-02 19:48:22 +030084 if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) {
85
86 /* Always calculate checksum, ignore bad checksum if requested */
87
88 status =
89 acpi_tb_verify_checksum(table_desc->pointer,
90 table_desc->length);
Bob Mooref3d2e782007-02-02 19:48:18 +030091 }
92
Bob Moorec5fc42a2007-02-02 19:48:19 +030093 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096/*******************************************************************************
97 *
Bob Mooref3d2e782007-02-02 19:48:18 +030098 * FUNCTION: acpi_tb_add_table
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 *
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300100 * PARAMETERS: table_desc - Table descriptor
Bob Mooref3d2e782007-02-02 19:48:18 +0300101 * table_index - Where the table index is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *
103 * RETURN: Status
104 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300105 * DESCRIPTION: This function is called to add the ACPI table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 *
107 ******************************************************************************/
108
Bob Mooref3d2e782007-02-02 19:48:18 +0300109acpi_status
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300110acpi_tb_add_table(struct acpi_table_desc *table_desc,
Bob Mooref3d2e782007-02-02 19:48:18 +0300111 acpi_native_uint * table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112{
Bob Mooref3d2e782007-02-02 19:48:18 +0300113 acpi_native_uint i;
114 acpi_native_uint length;
115 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Bob Mooref3d2e782007-02-02 19:48:18 +0300117 ACPI_FUNCTION_TRACE(tb_add_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300119 if (!table_desc->pointer) {
120 status = acpi_tb_verify_table(table_desc);
121 if (ACPI_FAILURE(status) || !table_desc->pointer) {
122 return_ACPI_STATUS(status);
123 }
124 }
125
Len Brown0efabac2007-05-24 02:25:00 -0400126 /* The table must be either an SSDT or a PSDT or an OEMx */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300127
Bob Moore5eb69182008-04-10 19:06:39 +0400128 if (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_PSDT)&&
129 !ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT)&&
130 strncmp(table_desc->pointer->signature, "OEM", 3)) {
131 /* Check for a printable name */
132 if (acpi_ut_valid_acpi_name(
133 *(u32 *) table_desc->pointer->signature)) {
134 ACPI_ERROR((AE_INFO, "Table has invalid signature "
135 "[%4.4s], must be SSDT or PSDT",
136 table_desc->pointer->signature));
137 } else {
138 ACPI_ERROR((AE_INFO, "Table has invalid signature "
139 "(0x%8.8X), must be SSDT or PSDT",
140 *(u32 *) table_desc->pointer->signature));
141 }
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300142 return_ACPI_STATUS(AE_BAD_SIGNATURE);
143 }
144
Bob Mooref3d2e782007-02-02 19:48:18 +0300145 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Bob Mooref3d2e782007-02-02 19:48:18 +0300147 /* Check if table is already registered */
148
149 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
150 if (!acpi_gbl_root_table_list.tables[i].pointer) {
151 status =
152 acpi_tb_verify_table(&acpi_gbl_root_table_list.
153 tables[i]);
154 if (ACPI_FAILURE(status)
155 || !acpi_gbl_root_table_list.tables[i].pointer) {
156 continue;
157 }
158 }
159
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300160 length = ACPI_MIN(table_desc->length,
161 acpi_gbl_root_table_list.tables[i].length);
162 if (ACPI_MEMCMP(table_desc->pointer,
163 acpi_gbl_root_table_list.tables[i].pointer,
164 length)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300165 continue;
166 }
167
168 /* Table is already registered */
169
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300170 acpi_tb_delete_table(table_desc);
Bob Mooref3d2e782007-02-02 19:48:18 +0300171 *table_index = i;
172 goto release;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 }
174
Robert Moore0c9938c2005-07-29 15:15:00 -0700175 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300176 * Add the table to the global table list
Robert Moore0c9938c2005-07-29 15:15:00 -0700177 */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300178 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
179 table_desc->length, table_desc->flags,
180 table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400181 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300182 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700183 }
184
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300185 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Bob Mooref3d2e782007-02-02 19:48:18 +0300187 release:
Len Brown4be44fc2005-08-05 00:44:28 -0400188 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
189 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190}
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192/*******************************************************************************
193 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300194 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300196 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 *
198 * RETURN: Status
199 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300200 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 *
202 ******************************************************************************/
203
Bob Mooref3d2e782007-02-02 19:48:18 +0300204acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205{
Bob Mooref3d2e782007-02-02 19:48:18 +0300206 struct acpi_table_desc *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Bob Mooref3d2e782007-02-02 19:48:18 +0300208 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Bob Mooref3d2e782007-02-02 19:48:18 +0300210 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
Bob Moorec5fc42a2007-02-02 19:48:19 +0300212 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300213 ACPI_ERROR((AE_INFO,
214 "Resize of Root Table Array is not allowed"));
215 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 }
217
Bob Mooref3d2e782007-02-02 19:48:18 +0300218 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Bob Mooref3d2e782007-02-02 19:48:18 +0300220 tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size +
221 ACPI_ROOT_TABLE_SIZE_INCREMENT)
222 * sizeof(struct acpi_table_desc));
223 if (!tables) {
224 ACPI_ERROR((AE_INFO,
225 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400226 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 }
228
Bob Mooref3d2e782007-02-02 19:48:18 +0300229 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400230
Bob Mooref3d2e782007-02-02 19:48:18 +0300231 if (acpi_gbl_root_table_list.tables) {
232 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
233 acpi_gbl_root_table_list.size *
234 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400235
Bob Moorec5fc42a2007-02-02 19:48:19 +0300236 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300237 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 }
239 }
240
Bob Mooref3d2e782007-02-02 19:48:18 +0300241 acpi_gbl_root_table_list.tables = tables;
242 acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
Bob Moorec5fc42a2007-02-02 19:48:19 +0300243 acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244
Len Brown4be44fc2005-08-05 00:44:28 -0400245 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246}
247
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248/*******************************************************************************
249 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300250 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300252 * PARAMETERS: Address - Table address
253 * Table - Table header
254 * Length - Table length
255 * Flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300257 * RETURN: Status and table index.
258 *
259 * DESCRIPTION: Add an ACPI table to the global table list
260 *
261 ******************************************************************************/
262
263acpi_status
264acpi_tb_store_table(acpi_physical_address address,
265 struct acpi_table_header *table,
266 u32 length, u8 flags, acpi_native_uint * table_index)
267{
268 acpi_status status = AE_OK;
269
270 /* Ensure that there is room for the table in the Root Table List */
271
272 if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) {
273 status = acpi_tb_resize_root_table_list();
274 if (ACPI_FAILURE(status)) {
275 return (status);
276 }
277 }
278
279 /* Initialize added table */
280
281 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
282 address = address;
283 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
284 pointer = table;
285 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length =
286 length;
287 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
288 owner_id = 0;
289 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags =
290 flags;
291
292 ACPI_MOVE_32_TO_32(&
293 (acpi_gbl_root_table_list.
294 tables[acpi_gbl_root_table_list.count].signature),
295 table->signature);
296
297 *table_index = acpi_gbl_root_table_list.count;
298 acpi_gbl_root_table_list.count++;
299 return (status);
300}
301
302/*******************************************************************************
303 *
304 * FUNCTION: acpi_tb_delete_table
305 *
306 * PARAMETERS: table_index - Table index
307 *
308 * RETURN: None
309 *
310 * DESCRIPTION: Delete one internal ACPI table
311 *
312 ******************************************************************************/
313
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300314void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
Bob Mooref3d2e782007-02-02 19:48:18 +0300315{
Bob Mooref3d2e782007-02-02 19:48:18 +0300316 /* Table must be mapped or allocated */
Bob Mooref3d2e782007-02-02 19:48:18 +0300317 if (!table_desc->pointer) {
318 return;
319 }
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300320 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
321 case ACPI_TABLE_ORIGIN_MAPPED:
322 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
323 break;
324 case ACPI_TABLE_ORIGIN_ALLOCATED:
Bob Mooref3d2e782007-02-02 19:48:18 +0300325 ACPI_FREE(table_desc->pointer);
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300326 break;
327 default:;
Bob Mooref3d2e782007-02-02 19:48:18 +0300328 }
329
330 table_desc->pointer = NULL;
331}
332
333/*******************************************************************************
334 *
335 * FUNCTION: acpi_tb_terminate
336 *
337 * PARAMETERS: None
338 *
339 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 *
341 * DESCRIPTION: Delete all internal ACPI tables
342 *
343 ******************************************************************************/
344
Bob Mooref3d2e782007-02-02 19:48:18 +0300345void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346{
Bob Mooref3d2e782007-02-02 19:48:18 +0300347 acpi_native_uint i;
348
349 ACPI_FUNCTION_TRACE(tb_terminate);
350
351 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
352
353 /* Delete the individual tables */
354
355 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300356 acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
Bob Mooref3d2e782007-02-02 19:48:18 +0300357 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300360 * Delete the root table array if allocated locally. Array cannot be
361 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300363 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300364 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300366
367 acpi_gbl_root_table_list.tables = NULL;
368 acpi_gbl_root_table_list.flags = 0;
369 acpi_gbl_root_table_list.count = 0;
370
371 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
372 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373}
374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375/*******************************************************************************
376 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300377 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300379 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300381 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300383 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 *
385 ******************************************************************************/
386
Bob Mooref3d2e782007-02-02 19:48:18 +0300387void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
Bob Mooref3d2e782007-02-02 19:48:18 +0300389 acpi_owner_id owner_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
Bob Mooref3d2e782007-02-02 19:48:18 +0300391 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
392 if (table_index < acpi_gbl_root_table_list.count) {
393 owner_id =
394 acpi_gbl_root_table_list.tables[table_index].owner_id;
395 } else {
396 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 return;
398 }
399
Len Brown4be44fc2005-08-05 00:44:28 -0400400 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Mooref3d2e782007-02-02 19:48:18 +0300401 acpi_ns_delete_namespace_by_owner(owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402}
403
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404/*******************************************************************************
405 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300406 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300408 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300410 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300412 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 *
414 ******************************************************************************/
415
Bob Mooref3d2e782007-02-02 19:48:18 +0300416acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
Bob Mooref3d2e782007-02-02 19:48:18 +0300418 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
Bob Mooref3d2e782007-02-02 19:48:18 +0300420 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
Bob Mooref3d2e782007-02-02 19:48:18 +0300422 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
423 if (table_index < acpi_gbl_root_table_list.count) {
424 status = acpi_ut_allocate_owner_id
425 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 }
427
Bob Mooref3d2e782007-02-02 19:48:18 +0300428 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
429 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430}
431
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432/*******************************************************************************
433 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300434 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300436 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300438 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300440 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 *
442 ******************************************************************************/
443
Bob Mooref3d2e782007-02-02 19:48:18 +0300444acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
Bob Mooref3d2e782007-02-02 19:48:18 +0300446 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Bob Mooref3d2e782007-02-02 19:48:18 +0300448 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
Bob Mooref3d2e782007-02-02 19:48:18 +0300450 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
451 if (table_index < acpi_gbl_root_table_list.count) {
452 acpi_ut_release_owner_id(&
453 (acpi_gbl_root_table_list.
454 tables[table_index].owner_id));
455 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 }
457
Bob Mooref3d2e782007-02-02 19:48:18 +0300458 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
459 return_ACPI_STATUS(status);
460}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
Bob Mooref3d2e782007-02-02 19:48:18 +0300462/*******************************************************************************
463 *
464 * FUNCTION: acpi_tb_get_owner_id
465 *
466 * PARAMETERS: table_index - Table index
467 * owner_id - Where the table owner_id is returned
468 *
469 * RETURN: Status
470 *
471 * DESCRIPTION: returns owner_id for the ACPI table
472 *
473 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474
Bob Mooref3d2e782007-02-02 19:48:18 +0300475acpi_status
476acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id)
477{
478 acpi_status status = AE_BAD_PARAMETER;
479
480 ACPI_FUNCTION_TRACE(tb_get_owner_id);
481
482 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
483 if (table_index < acpi_gbl_root_table_list.count) {
484 *owner_id =
485 acpi_gbl_root_table_list.tables[table_index].owner_id;
486 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 }
488
Bob Mooref3d2e782007-02-02 19:48:18 +0300489 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
490 return_ACPI_STATUS(status);
491}
492
493/*******************************************************************************
494 *
495 * FUNCTION: acpi_tb_is_table_loaded
496 *
497 * PARAMETERS: table_index - Table index
498 *
499 * RETURN: Table Loaded Flag
500 *
501 ******************************************************************************/
502
503u8 acpi_tb_is_table_loaded(acpi_native_uint table_index)
504{
505 u8 is_loaded = FALSE;
506
507 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
508 if (table_index < acpi_gbl_root_table_list.count) {
509 is_loaded = (u8)
510 (acpi_gbl_root_table_list.tables[table_index].
Bob Moorec5fc42a2007-02-02 19:48:19 +0300511 flags & ACPI_TABLE_IS_LOADED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 }
513
Bob Mooref3d2e782007-02-02 19:48:18 +0300514 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
515 return (is_loaded);
516}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517
Bob Mooref3d2e782007-02-02 19:48:18 +0300518/*******************************************************************************
519 *
520 * FUNCTION: acpi_tb_set_table_loaded_flag
521 *
522 * PARAMETERS: table_index - Table index
523 * is_loaded - TRUE if table is loaded, FALSE otherwise
524 *
525 * RETURN: None
526 *
527 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
528 *
529 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Bob Mooref3d2e782007-02-02 19:48:18 +0300531void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded)
532{
Bob Mooref6dd9222006-07-07 20:44:38 -0400533
Bob Mooref3d2e782007-02-02 19:48:18 +0300534 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
535 if (table_index < acpi_gbl_root_table_list.count) {
536 if (is_loaded) {
537 acpi_gbl_root_table_list.tables[table_index].flags |=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300538 ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300539 } else {
540 acpi_gbl_root_table_list.tables[table_index].flags &=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300541 ~ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300542 }
543 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400544
Bob Mooref3d2e782007-02-02 19:48:18 +0300545 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546}