blob: 905dc38ab23b3528d3fbbcaa4f54408e09125383 [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/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, Intel Corp.
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
Bob Moore67a119f2008-06-10 13:42:13 +0800110acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
Bob Moore67a119f2008-06-10 13:42:13 +0800112 u32 i;
113 u32 length;
Bob Mooref3d2e782007-02-02 19:48:18 +0300114 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Bob Mooref3d2e782007-02-02 19:48:18 +0300116 ACPI_FUNCTION_TRACE(tb_add_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300118 if (!table_desc->pointer) {
119 status = acpi_tb_verify_table(table_desc);
120 if (ACPI_FAILURE(status) || !table_desc->pointer) {
121 return_ACPI_STATUS(status);
122 }
123 }
124
Bob Moorebc45b1d2008-06-10 14:12:50 +0800125 /*
126 * Originally, we checked the table signature for "SSDT" or "PSDT" here.
127 * Next, we added support for OEMx tables, signature "OEM".
128 * Valid tables were encountered with a null signature, so we've just
129 * given up on validating the signature, since it seems to be a waste
130 * of code. The original code was removed (05/2008).
131 */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300132
Bob Mooref3d2e782007-02-02 19:48:18 +0300133 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Bob Mooref3d2e782007-02-02 19:48:18 +0300135 /* Check if table is already registered */
136
137 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
138 if (!acpi_gbl_root_table_list.tables[i].pointer) {
139 status =
140 acpi_tb_verify_table(&acpi_gbl_root_table_list.
141 tables[i]);
142 if (ACPI_FAILURE(status)
143 || !acpi_gbl_root_table_list.tables[i].pointer) {
144 continue;
145 }
146 }
147
Bob Mooree56f5612008-07-04 10:48:43 +0800148 /* Check for a table match on the entire table length */
149
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300150 length = ACPI_MIN(table_desc->length,
151 acpi_gbl_root_table_list.tables[i].length);
152 if (ACPI_MEMCMP(table_desc->pointer,
153 acpi_gbl_root_table_list.tables[i].pointer,
154 length)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300155 continue;
156 }
157
Bob Mooree56f5612008-07-04 10:48:43 +0800158 /*
159 * Note: the current mechanism does not unregister a table if it is
160 * dynamically unloaded. The related namespace entries are deleted,
161 * but the table remains in the root table list.
162 *
163 * The assumption here is that the number of different tables that
164 * will be loaded is actually small, and there is minimal overhead
165 * in just keeping the table in case it is needed again.
166 *
167 * If this assumption changes in the future (perhaps on large
168 * machines with many table load/unload operations), tables will
169 * need to be unregistered when they are unloaded, and slots in the
170 * root table list should be reused when empty.
171 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300172
Bob Mooree56f5612008-07-04 10:48:43 +0800173 /*
174 * Table is already registered.
175 * We can delete the table that was passed as a parameter.
176 */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300177 acpi_tb_delete_table(table_desc);
Bob Mooref3d2e782007-02-02 19:48:18 +0300178 *table_index = i;
Bob Mooree56f5612008-07-04 10:48:43 +0800179
180 if (acpi_gbl_root_table_list.tables[i].
181 flags & ACPI_TABLE_IS_LOADED) {
182
183 /* Table is still loaded, this is an error */
184
185 status = AE_ALREADY_EXISTS;
186 goto release;
187 } else {
188 /* Table was unloaded, allow it to be reloaded */
189
190 table_desc->pointer =
191 acpi_gbl_root_table_list.tables[i].pointer;
192 table_desc->address =
193 acpi_gbl_root_table_list.tables[i].address;
194 status = AE_OK;
195 goto print_header;
196 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 }
198
Bob Mooree56f5612008-07-04 10:48:43 +0800199 /* Add the table to the global root table list */
200
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300201 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
202 table_desc->length, table_desc->flags,
203 table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400204 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300205 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700206 }
207
Bob Mooree56f5612008-07-04 10:48:43 +0800208 print_header:
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300209 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Bob Mooref3d2e782007-02-02 19:48:18 +0300211 release:
Len Brown4be44fc2005-08-05 00:44:28 -0400212 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
213 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214}
215
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216/*******************************************************************************
217 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300218 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300220 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 *
222 * RETURN: Status
223 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300224 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 *
226 ******************************************************************************/
227
Bob Mooref3d2e782007-02-02 19:48:18 +0300228acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229{
Bob Mooref3d2e782007-02-02 19:48:18 +0300230 struct acpi_table_desc *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
Bob Mooref3d2e782007-02-02 19:48:18 +0300232 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
Bob Mooref3d2e782007-02-02 19:48:18 +0300234 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Bob Moorec5fc42a2007-02-02 19:48:19 +0300236 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300237 ACPI_ERROR((AE_INFO,
238 "Resize of Root Table Array is not allowed"));
239 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 }
241
Bob Mooref3d2e782007-02-02 19:48:18 +0300242 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Bob Moore67a119f2008-06-10 13:42:13 +0800244 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list.
245 size + ACPI_ROOT_TABLE_SIZE_INCREMENT)
Bob Mooref3d2e782007-02-02 19:48:18 +0300246 * sizeof(struct acpi_table_desc));
247 if (!tables) {
248 ACPI_ERROR((AE_INFO,
249 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400250 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 }
252
Bob Mooref3d2e782007-02-02 19:48:18 +0300253 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400254
Bob Mooref3d2e782007-02-02 19:48:18 +0300255 if (acpi_gbl_root_table_list.tables) {
256 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
Bob Moore67a119f2008-06-10 13:42:13 +0800257 (acpi_size) acpi_gbl_root_table_list.size *
Bob Mooref3d2e782007-02-02 19:48:18 +0300258 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400259
Bob Moorec5fc42a2007-02-02 19:48:19 +0300260 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300261 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 }
263 }
264
Bob Mooref3d2e782007-02-02 19:48:18 +0300265 acpi_gbl_root_table_list.tables = tables;
266 acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
Bob Moorec5fc42a2007-02-02 19:48:19 +0300267 acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Len Brown4be44fc2005-08-05 00:44:28 -0400269 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270}
271
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272/*******************************************************************************
273 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300274 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300276 * PARAMETERS: Address - Table address
277 * Table - Table header
278 * Length - Table length
279 * Flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300281 * RETURN: Status and table index.
282 *
283 * DESCRIPTION: Add an ACPI table to the global table list
284 *
285 ******************************************************************************/
286
287acpi_status
288acpi_tb_store_table(acpi_physical_address address,
289 struct acpi_table_header *table,
Bob Moore67a119f2008-06-10 13:42:13 +0800290 u32 length, u8 flags, u32 *table_index)
Bob Mooref3d2e782007-02-02 19:48:18 +0300291{
292 acpi_status status = AE_OK;
293
294 /* Ensure that there is room for the table in the Root Table List */
295
296 if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) {
297 status = acpi_tb_resize_root_table_list();
298 if (ACPI_FAILURE(status)) {
299 return (status);
300 }
301 }
302
303 /* Initialize added table */
304
305 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
306 address = address;
307 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
308 pointer = table;
309 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length =
310 length;
311 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
312 owner_id = 0;
313 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags =
314 flags;
315
316 ACPI_MOVE_32_TO_32(&
317 (acpi_gbl_root_table_list.
318 tables[acpi_gbl_root_table_list.count].signature),
319 table->signature);
320
321 *table_index = acpi_gbl_root_table_list.count;
322 acpi_gbl_root_table_list.count++;
323 return (status);
324}
325
326/*******************************************************************************
327 *
328 * FUNCTION: acpi_tb_delete_table
329 *
330 * PARAMETERS: table_index - Table index
331 *
332 * RETURN: None
333 *
334 * DESCRIPTION: Delete one internal ACPI table
335 *
336 ******************************************************************************/
337
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300338void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
Bob Mooref3d2e782007-02-02 19:48:18 +0300339{
Bob Mooref3d2e782007-02-02 19:48:18 +0300340 /* Table must be mapped or allocated */
Bob Mooref3d2e782007-02-02 19:48:18 +0300341 if (!table_desc->pointer) {
342 return;
343 }
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300344 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
345 case ACPI_TABLE_ORIGIN_MAPPED:
346 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
347 break;
348 case ACPI_TABLE_ORIGIN_ALLOCATED:
Bob Mooref3d2e782007-02-02 19:48:18 +0300349 ACPI_FREE(table_desc->pointer);
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300350 break;
351 default:;
Bob Mooref3d2e782007-02-02 19:48:18 +0300352 }
353
354 table_desc->pointer = NULL;
355}
356
357/*******************************************************************************
358 *
359 * FUNCTION: acpi_tb_terminate
360 *
361 * PARAMETERS: None
362 *
363 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 *
365 * DESCRIPTION: Delete all internal ACPI tables
366 *
367 ******************************************************************************/
368
Bob Mooref3d2e782007-02-02 19:48:18 +0300369void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
Bob Moore67a119f2008-06-10 13:42:13 +0800371 u32 i;
Bob Mooref3d2e782007-02-02 19:48:18 +0300372
373 ACPI_FUNCTION_TRACE(tb_terminate);
374
375 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
376
377 /* Delete the individual tables */
378
379 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300380 acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
Bob Mooref3d2e782007-02-02 19:48:18 +0300381 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300384 * Delete the root table array if allocated locally. Array cannot be
385 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300387 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300388 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300390
391 acpi_gbl_root_table_list.tables = NULL;
392 acpi_gbl_root_table_list.flags = 0;
393 acpi_gbl_root_table_list.count = 0;
394
395 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
396 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397}
398
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399/*******************************************************************************
400 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300401 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300403 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300405 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300407 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 *
409 ******************************************************************************/
410
Bob Moore67a119f2008-06-10 13:42:13 +0800411void acpi_tb_delete_namespace_by_owner(u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412{
Bob Mooref3d2e782007-02-02 19:48:18 +0300413 acpi_owner_id owner_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Bob Mooref3d2e782007-02-02 19:48:18 +0300415 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
416 if (table_index < acpi_gbl_root_table_list.count) {
417 owner_id =
418 acpi_gbl_root_table_list.tables[table_index].owner_id;
419 } else {
420 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 return;
422 }
423
Len Brown4be44fc2005-08-05 00:44:28 -0400424 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Mooref3d2e782007-02-02 19:48:18 +0300425 acpi_ns_delete_namespace_by_owner(owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426}
427
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428/*******************************************************************************
429 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300430 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300432 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300434 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300436 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 *
438 ******************************************************************************/
439
Bob Moore67a119f2008-06-10 13:42:13 +0800440acpi_status acpi_tb_allocate_owner_id(u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441{
Bob Mooref3d2e782007-02-02 19:48:18 +0300442 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Bob Mooref3d2e782007-02-02 19:48:18 +0300444 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
Bob Mooref3d2e782007-02-02 19:48:18 +0300446 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
447 if (table_index < acpi_gbl_root_table_list.count) {
448 status = acpi_ut_allocate_owner_id
449 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 }
451
Bob Mooref3d2e782007-02-02 19:48:18 +0300452 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
453 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/*******************************************************************************
457 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300458 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300460 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300462 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300464 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 *
466 ******************************************************************************/
467
Bob Moore67a119f2008-06-10 13:42:13 +0800468acpi_status acpi_tb_release_owner_id(u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
Bob Mooref3d2e782007-02-02 19:48:18 +0300470 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Bob Mooref3d2e782007-02-02 19:48:18 +0300472 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Bob Mooref3d2e782007-02-02 19:48:18 +0300474 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
475 if (table_index < acpi_gbl_root_table_list.count) {
476 acpi_ut_release_owner_id(&
477 (acpi_gbl_root_table_list.
478 tables[table_index].owner_id));
479 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 }
481
Bob Mooref3d2e782007-02-02 19:48:18 +0300482 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
483 return_ACPI_STATUS(status);
484}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Bob Mooref3d2e782007-02-02 19:48:18 +0300486/*******************************************************************************
487 *
488 * FUNCTION: acpi_tb_get_owner_id
489 *
490 * PARAMETERS: table_index - Table index
491 * owner_id - Where the table owner_id is returned
492 *
493 * RETURN: Status
494 *
495 * DESCRIPTION: returns owner_id for the ACPI table
496 *
497 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Bob Moore67a119f2008-06-10 13:42:13 +0800499acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
Bob Mooref3d2e782007-02-02 19:48:18 +0300500{
501 acpi_status status = AE_BAD_PARAMETER;
502
503 ACPI_FUNCTION_TRACE(tb_get_owner_id);
504
505 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
506 if (table_index < acpi_gbl_root_table_list.count) {
507 *owner_id =
508 acpi_gbl_root_table_list.tables[table_index].owner_id;
509 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 }
511
Bob Mooref3d2e782007-02-02 19:48:18 +0300512 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
513 return_ACPI_STATUS(status);
514}
515
516/*******************************************************************************
517 *
518 * FUNCTION: acpi_tb_is_table_loaded
519 *
520 * PARAMETERS: table_index - Table index
521 *
522 * RETURN: Table Loaded Flag
523 *
524 ******************************************************************************/
525
Bob Moore67a119f2008-06-10 13:42:13 +0800526u8 acpi_tb_is_table_loaded(u32 table_index)
Bob Mooref3d2e782007-02-02 19:48:18 +0300527{
528 u8 is_loaded = FALSE;
529
530 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
531 if (table_index < acpi_gbl_root_table_list.count) {
532 is_loaded = (u8)
533 (acpi_gbl_root_table_list.tables[table_index].
Bob Moorec5fc42a2007-02-02 19:48:19 +0300534 flags & ACPI_TABLE_IS_LOADED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 }
536
Bob Mooref3d2e782007-02-02 19:48:18 +0300537 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
538 return (is_loaded);
539}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540
Bob Mooref3d2e782007-02-02 19:48:18 +0300541/*******************************************************************************
542 *
543 * FUNCTION: acpi_tb_set_table_loaded_flag
544 *
545 * PARAMETERS: table_index - Table index
546 * is_loaded - TRUE if table is loaded, FALSE otherwise
547 *
548 * RETURN: None
549 *
550 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
551 *
552 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553
Bob Moore67a119f2008-06-10 13:42:13 +0800554void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
Bob Mooref3d2e782007-02-02 19:48:18 +0300555{
Bob Mooref6dd9222006-07-07 20:44:38 -0400556
Bob Mooref3d2e782007-02-02 19:48:18 +0300557 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
558 if (table_index < acpi_gbl_root_table_list.count) {
559 if (is_loaded) {
560 acpi_gbl_root_table_list.tables[table_index].flags |=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300561 ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300562 } else {
563 acpi_gbl_root_table_list.tables[table_index].flags &=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300564 ~ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300565 }
566 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400567
Bob Mooref3d2e782007-02-02 19:48:18 +0300568 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569}