blob: c4a9abb072c03f9e3d1a50939334850559b34c4b [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;
Lin Ming200cce62008-04-10 19:06:42 +0400172 status = AE_ALREADY_EXISTS;
Bob Mooref3d2e782007-02-02 19:48:18 +0300173 goto release;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 }
175
Robert Moore0c9938c2005-07-29 15:15:00 -0700176 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300177 * Add the table to the global table list
Robert Moore0c9938c2005-07-29 15:15:00 -0700178 */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300179 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
180 table_desc->length, table_desc->flags,
181 table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400182 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300183 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700184 }
185
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300186 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Bob Mooref3d2e782007-02-02 19:48:18 +0300188 release:
Len Brown4be44fc2005-08-05 00:44:28 -0400189 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
190 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191}
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/*******************************************************************************
194 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300195 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300197 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 *
199 * RETURN: Status
200 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300201 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 *
203 ******************************************************************************/
204
Bob Mooref3d2e782007-02-02 19:48:18 +0300205acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206{
Bob Mooref3d2e782007-02-02 19:48:18 +0300207 struct acpi_table_desc *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Bob Mooref3d2e782007-02-02 19:48:18 +0300209 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Bob Mooref3d2e782007-02-02 19:48:18 +0300211 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Bob Moorec5fc42a2007-02-02 19:48:19 +0300213 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300214 ACPI_ERROR((AE_INFO,
215 "Resize of Root Table Array is not allowed"));
216 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 }
218
Bob Mooref3d2e782007-02-02 19:48:18 +0300219 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Bob Mooref3d2e782007-02-02 19:48:18 +0300221 tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size +
222 ACPI_ROOT_TABLE_SIZE_INCREMENT)
223 * sizeof(struct acpi_table_desc));
224 if (!tables) {
225 ACPI_ERROR((AE_INFO,
226 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400227 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 }
229
Bob Mooref3d2e782007-02-02 19:48:18 +0300230 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400231
Bob Mooref3d2e782007-02-02 19:48:18 +0300232 if (acpi_gbl_root_table_list.tables) {
233 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
234 acpi_gbl_root_table_list.size *
235 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400236
Bob Moorec5fc42a2007-02-02 19:48:19 +0300237 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300238 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 }
240 }
241
Bob Mooref3d2e782007-02-02 19:48:18 +0300242 acpi_gbl_root_table_list.tables = tables;
243 acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
Bob Moorec5fc42a2007-02-02 19:48:19 +0300244 acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245
Len Brown4be44fc2005-08-05 00:44:28 -0400246 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247}
248
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249/*******************************************************************************
250 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300251 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300253 * PARAMETERS: Address - Table address
254 * Table - Table header
255 * Length - Table length
256 * Flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300258 * RETURN: Status and table index.
259 *
260 * DESCRIPTION: Add an ACPI table to the global table list
261 *
262 ******************************************************************************/
263
264acpi_status
265acpi_tb_store_table(acpi_physical_address address,
266 struct acpi_table_header *table,
267 u32 length, u8 flags, acpi_native_uint * table_index)
268{
269 acpi_status status = AE_OK;
270
271 /* Ensure that there is room for the table in the Root Table List */
272
273 if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) {
274 status = acpi_tb_resize_root_table_list();
275 if (ACPI_FAILURE(status)) {
276 return (status);
277 }
278 }
279
280 /* Initialize added table */
281
282 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
283 address = address;
284 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
285 pointer = table;
286 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length =
287 length;
288 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
289 owner_id = 0;
290 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags =
291 flags;
292
293 ACPI_MOVE_32_TO_32(&
294 (acpi_gbl_root_table_list.
295 tables[acpi_gbl_root_table_list.count].signature),
296 table->signature);
297
298 *table_index = acpi_gbl_root_table_list.count;
299 acpi_gbl_root_table_list.count++;
300 return (status);
301}
302
303/*******************************************************************************
304 *
305 * FUNCTION: acpi_tb_delete_table
306 *
307 * PARAMETERS: table_index - Table index
308 *
309 * RETURN: None
310 *
311 * DESCRIPTION: Delete one internal ACPI table
312 *
313 ******************************************************************************/
314
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300315void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
Bob Mooref3d2e782007-02-02 19:48:18 +0300316{
Bob Mooref3d2e782007-02-02 19:48:18 +0300317 /* Table must be mapped or allocated */
Bob Mooref3d2e782007-02-02 19:48:18 +0300318 if (!table_desc->pointer) {
319 return;
320 }
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300321 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
322 case ACPI_TABLE_ORIGIN_MAPPED:
323 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
324 break;
325 case ACPI_TABLE_ORIGIN_ALLOCATED:
Bob Mooref3d2e782007-02-02 19:48:18 +0300326 ACPI_FREE(table_desc->pointer);
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300327 break;
328 default:;
Bob Mooref3d2e782007-02-02 19:48:18 +0300329 }
330
331 table_desc->pointer = NULL;
332}
333
334/*******************************************************************************
335 *
336 * FUNCTION: acpi_tb_terminate
337 *
338 * PARAMETERS: None
339 *
340 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 *
342 * DESCRIPTION: Delete all internal ACPI tables
343 *
344 ******************************************************************************/
345
Bob Mooref3d2e782007-02-02 19:48:18 +0300346void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347{
Bob Mooref3d2e782007-02-02 19:48:18 +0300348 acpi_native_uint i;
349
350 ACPI_FUNCTION_TRACE(tb_terminate);
351
352 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
353
354 /* Delete the individual tables */
355
356 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300357 acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
Bob Mooref3d2e782007-02-02 19:48:18 +0300358 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300361 * Delete the root table array if allocated locally. Array cannot be
362 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300364 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300365 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300367
368 acpi_gbl_root_table_list.tables = NULL;
369 acpi_gbl_root_table_list.flags = 0;
370 acpi_gbl_root_table_list.count = 0;
371
372 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
373 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374}
375
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376/*******************************************************************************
377 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300378 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300380 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300382 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300384 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 *
386 ******************************************************************************/
387
Bob Mooref3d2e782007-02-02 19:48:18 +0300388void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389{
Bob Mooref3d2e782007-02-02 19:48:18 +0300390 acpi_owner_id owner_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Bob Mooref3d2e782007-02-02 19:48:18 +0300392 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
393 if (table_index < acpi_gbl_root_table_list.count) {
394 owner_id =
395 acpi_gbl_root_table_list.tables[table_index].owner_id;
396 } else {
397 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 return;
399 }
400
Len Brown4be44fc2005-08-05 00:44:28 -0400401 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Mooref3d2e782007-02-02 19:48:18 +0300402 acpi_ns_delete_namespace_by_owner(owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403}
404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405/*******************************************************************************
406 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300407 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300409 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300411 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300413 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 *
415 ******************************************************************************/
416
Bob Mooref3d2e782007-02-02 19:48:18 +0300417acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
Bob Mooref3d2e782007-02-02 19:48:18 +0300419 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Bob Mooref3d2e782007-02-02 19:48:18 +0300421 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422
Bob Mooref3d2e782007-02-02 19:48:18 +0300423 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
424 if (table_index < acpi_gbl_root_table_list.count) {
425 status = acpi_ut_allocate_owner_id
426 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 }
428
Bob Mooref3d2e782007-02-02 19:48:18 +0300429 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
430 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431}
432
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433/*******************************************************************************
434 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300435 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300437 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300439 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300441 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 *
443 ******************************************************************************/
444
Bob Mooref3d2e782007-02-02 19:48:18 +0300445acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
Bob Mooref3d2e782007-02-02 19:48:18 +0300447 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
Bob Mooref3d2e782007-02-02 19:48:18 +0300449 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bob Mooref3d2e782007-02-02 19:48:18 +0300451 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
452 if (table_index < acpi_gbl_root_table_list.count) {
453 acpi_ut_release_owner_id(&
454 (acpi_gbl_root_table_list.
455 tables[table_index].owner_id));
456 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 }
458
Bob Mooref3d2e782007-02-02 19:48:18 +0300459 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
460 return_ACPI_STATUS(status);
461}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
Bob Mooref3d2e782007-02-02 19:48:18 +0300463/*******************************************************************************
464 *
465 * FUNCTION: acpi_tb_get_owner_id
466 *
467 * PARAMETERS: table_index - Table index
468 * owner_id - Where the table owner_id is returned
469 *
470 * RETURN: Status
471 *
472 * DESCRIPTION: returns owner_id for the ACPI table
473 *
474 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Bob Mooref3d2e782007-02-02 19:48:18 +0300476acpi_status
477acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id)
478{
479 acpi_status status = AE_BAD_PARAMETER;
480
481 ACPI_FUNCTION_TRACE(tb_get_owner_id);
482
483 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
484 if (table_index < acpi_gbl_root_table_list.count) {
485 *owner_id =
486 acpi_gbl_root_table_list.tables[table_index].owner_id;
487 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 }
489
Bob Mooref3d2e782007-02-02 19:48:18 +0300490 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
491 return_ACPI_STATUS(status);
492}
493
494/*******************************************************************************
495 *
496 * FUNCTION: acpi_tb_is_table_loaded
497 *
498 * PARAMETERS: table_index - Table index
499 *
500 * RETURN: Table Loaded Flag
501 *
502 ******************************************************************************/
503
504u8 acpi_tb_is_table_loaded(acpi_native_uint table_index)
505{
506 u8 is_loaded = FALSE;
507
508 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
509 if (table_index < acpi_gbl_root_table_list.count) {
510 is_loaded = (u8)
511 (acpi_gbl_root_table_list.tables[table_index].
Bob Moorec5fc42a2007-02-02 19:48:19 +0300512 flags & ACPI_TABLE_IS_LOADED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 }
514
Bob Mooref3d2e782007-02-02 19:48:18 +0300515 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
516 return (is_loaded);
517}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
Bob Mooref3d2e782007-02-02 19:48:18 +0300519/*******************************************************************************
520 *
521 * FUNCTION: acpi_tb_set_table_loaded_flag
522 *
523 * PARAMETERS: table_index - Table index
524 * is_loaded - TRUE if table is loaded, FALSE otherwise
525 *
526 * RETURN: None
527 *
528 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
529 *
530 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531
Bob Mooref3d2e782007-02-02 19:48:18 +0300532void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded)
533{
Bob Mooref6dd9222006-07-07 20:44:38 -0400534
Bob Mooref3d2e782007-02-02 19:48:18 +0300535 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
536 if (table_index < acpi_gbl_root_table_list.count) {
537 if (is_loaded) {
538 acpi_gbl_root_table_list.tables[table_index].flags |=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300539 ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300540 } else {
541 acpi_gbl_root_table_list.tables[table_index].flags &=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300542 ~ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300543 }
544 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400545
Bob Mooref3d2e782007-02-02 19:48:18 +0300546 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}