blob: 9076ca0913b768cfdfbc9cd906eb3a247cbc0638 [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 Moore4a90c7e2006-01-13 16:22:00 -05008 * Copyright (C) 2000 - 2006, 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{
Bob Mooref3d2e782007-02-02 19:48:18 +030064 u8 checksum;
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) {
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 Torvalds1da177e2005-04-16 15:20:36 -070076 }
77 }
78
Bob Mooref3d2e782007-02-02 19:48:18 +030079 /* FACS is the odd table, has no standard ACPI header and no checksum */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Bob Mooref3d2e782007-02-02 19:48:18 +030081 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
87 checksum = acpi_tb_checksum(ACPI_CAST_PTR(void, table_desc->pointer),
88 table_desc->length);
89
90#if (ACPI_CHECKSUM_ABORT)
91
92 if (checksum) {
93 return_ACPI_STATUS(AE_BAD_CHECKSUM);
94 }
95#endif
96
97 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100/*******************************************************************************
101 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300102 * FUNCTION: acpi_tb_add_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300104 * PARAMETERS: Table - Pointer to the table header
105 * table_index - Where the table index is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 *
107 * RETURN: Status
108 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300109 * DESCRIPTION: This function is called to add the ACPI table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 *
111 ******************************************************************************/
112
Bob Mooref3d2e782007-02-02 19:48:18 +0300113acpi_status
114acpi_tb_add_table(struct acpi_table_header *table,
115 acpi_native_uint * table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
Bob Mooref3d2e782007-02-02 19:48:18 +0300117 acpi_native_uint i;
118 acpi_native_uint length;
119 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Bob Mooref3d2e782007-02-02 19:48:18 +0300121 ACPI_FUNCTION_TRACE(tb_add_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Bob Mooref3d2e782007-02-02 19:48:18 +0300123 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
Bob Mooref3d2e782007-02-02 19:48:18 +0300125 /* Check if table is already registered */
126
127 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
128 if (!acpi_gbl_root_table_list.tables[i].pointer) {
129 status =
130 acpi_tb_verify_table(&acpi_gbl_root_table_list.
131 tables[i]);
132 if (ACPI_FAILURE(status)
133 || !acpi_gbl_root_table_list.tables[i].pointer) {
134 continue;
135 }
136 }
137
138 length = ACPI_MIN(table->length,
139 acpi_gbl_root_table_list.tables[i].pointer->
140 length);
141 if (ACPI_MEMCMP
142 (table, acpi_gbl_root_table_list.tables[i].pointer,
143 length)) {
144 continue;
145 }
146
147 /* Table is already registered */
148
149 ACPI_FREE(table);
150 *table_index = i;
151 goto release;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 }
153
Robert Moore0c9938c2005-07-29 15:15:00 -0700154 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300155 * Add the table to the global table list
Robert Moore0c9938c2005-07-29 15:15:00 -0700156 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300157 status = acpi_tb_store_table(ACPI_TO_INTEGER(table),
158 table, table->length,
159 ACPI_TABLE_ORIGIN_ALLOCATED, table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400160 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300161 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700162 }
163
Bob Mooref3d2e782007-02-02 19:48:18 +0300164 acpi_tb_print_table_header(0, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Bob Mooref3d2e782007-02-02 19:48:18 +0300166 release:
Len Brown4be44fc2005-08-05 00:44:28 -0400167 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
168 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169}
170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171/*******************************************************************************
172 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300173 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300175 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 *
177 * RETURN: Status
178 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300179 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 *
181 ******************************************************************************/
182
Bob Mooref3d2e782007-02-02 19:48:18 +0300183acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184{
Bob Mooref3d2e782007-02-02 19:48:18 +0300185 struct acpi_table_desc *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Bob Mooref3d2e782007-02-02 19:48:18 +0300187 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Bob Mooref3d2e782007-02-02 19:48:18 +0300189 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Bob Mooref3d2e782007-02-02 19:48:18 +0300191 if (!(acpi_gbl_root_table_list.flags & ACPI_TABLE_FLAGS_ALLOW_RESIZE)) {
192 ACPI_ERROR((AE_INFO,
193 "Resize of Root Table Array is not allowed"));
194 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 }
196
Bob Mooref3d2e782007-02-02 19:48:18 +0300197 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Bob Mooref3d2e782007-02-02 19:48:18 +0300199 tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size +
200 ACPI_ROOT_TABLE_SIZE_INCREMENT)
201 * sizeof(struct acpi_table_desc));
202 if (!tables) {
203 ACPI_ERROR((AE_INFO,
204 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400205 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 }
207
Bob Mooref3d2e782007-02-02 19:48:18 +0300208 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400209
Bob Mooref3d2e782007-02-02 19:48:18 +0300210 if (acpi_gbl_root_table_list.tables) {
211 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
212 acpi_gbl_root_table_list.size *
213 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400214
Bob Mooref3d2e782007-02-02 19:48:18 +0300215 if (acpi_gbl_root_table_list.flags & ACPI_TABLE_ORIGIN_MASK ==
216 ACPI_TABLE_ORIGIN_ALLOCATED) {
217 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 }
219 }
220
Bob Mooref3d2e782007-02-02 19:48:18 +0300221 acpi_gbl_root_table_list.tables = tables;
222 acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
223 acpi_gbl_root_table_list.flags = (u8) (ACPI_TABLE_ORIGIN_ALLOCATED |
224 (acpi_gbl_root_table_list.
225 flags &
226 ~ACPI_TABLE_ORIGIN_MASK));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Len Brown4be44fc2005-08-05 00:44:28 -0400228 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229}
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231/*******************************************************************************
232 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300233 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300235 * PARAMETERS: Address - Table address
236 * Table - Table header
237 * Length - Table length
238 * Flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300240 * RETURN: Status and table index.
241 *
242 * DESCRIPTION: Add an ACPI table to the global table list
243 *
244 ******************************************************************************/
245
246acpi_status
247acpi_tb_store_table(acpi_physical_address address,
248 struct acpi_table_header *table,
249 u32 length, u8 flags, acpi_native_uint * table_index)
250{
251 acpi_status status = AE_OK;
252
253 /* Ensure that there is room for the table in the Root Table List */
254
255 if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) {
256 status = acpi_tb_resize_root_table_list();
257 if (ACPI_FAILURE(status)) {
258 return (status);
259 }
260 }
261
262 /* Initialize added table */
263
264 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
265 address = address;
266 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
267 pointer = table;
268 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length =
269 length;
270 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
271 owner_id = 0;
272 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags =
273 flags;
274
275 ACPI_MOVE_32_TO_32(&
276 (acpi_gbl_root_table_list.
277 tables[acpi_gbl_root_table_list.count].signature),
278 table->signature);
279
280 *table_index = acpi_gbl_root_table_list.count;
281 acpi_gbl_root_table_list.count++;
282 return (status);
283}
284
285/*******************************************************************************
286 *
287 * FUNCTION: acpi_tb_delete_table
288 *
289 * PARAMETERS: table_index - Table index
290 *
291 * RETURN: None
292 *
293 * DESCRIPTION: Delete one internal ACPI table
294 *
295 ******************************************************************************/
296
297void acpi_tb_delete_table(acpi_native_uint table_index)
298{
299 struct acpi_table_desc *table_desc;
300
301 /* table_index assumed valid */
302
303 table_desc = &acpi_gbl_root_table_list.tables[table_index];
304
305 /* Table must be mapped or allocated */
306
307 if (!table_desc->pointer) {
308 return;
309 }
310
311 if (table_desc->flags & ACPI_TABLE_ORIGIN_MAPPED) {
312 acpi_tb_unmap(table_desc->pointer, table_desc->length,
313 table_desc->flags & ACPI_TABLE_ORIGIN_MASK);
314 } else if (table_desc->flags & ACPI_TABLE_ORIGIN_ALLOCATED) {
315 ACPI_FREE(table_desc->pointer);
316 }
317
318 table_desc->pointer = NULL;
319}
320
321/*******************************************************************************
322 *
323 * FUNCTION: acpi_tb_terminate
324 *
325 * PARAMETERS: None
326 *
327 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 *
329 * DESCRIPTION: Delete all internal ACPI tables
330 *
331 ******************************************************************************/
332
Bob Mooref3d2e782007-02-02 19:48:18 +0300333void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
Bob Mooref3d2e782007-02-02 19:48:18 +0300335 acpi_native_uint i;
336
337 ACPI_FUNCTION_TRACE(tb_terminate);
338
339 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
340
341 /* Delete the individual tables */
342
343 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
344 acpi_tb_delete_table(i);
345 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300348 * Delete the root table array if allocated locally. Array cannot be
349 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300351 if ((acpi_gbl_root_table_list.flags & ACPI_TABLE_ORIGIN_MASK) ==
352 ACPI_TABLE_ORIGIN_ALLOCATED) {
353 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300355
356 acpi_gbl_root_table_list.tables = NULL;
357 acpi_gbl_root_table_list.flags = 0;
358 acpi_gbl_root_table_list.count = 0;
359
360 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
361 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362}
363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364/*******************************************************************************
365 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300366 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300368 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300370 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300372 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 *
374 ******************************************************************************/
375
Bob Mooref3d2e782007-02-02 19:48:18 +0300376void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377{
Bob Mooref3d2e782007-02-02 19:48:18 +0300378 acpi_owner_id owner_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
Bob Mooref3d2e782007-02-02 19:48:18 +0300380 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
381 if (table_index < acpi_gbl_root_table_list.count) {
382 owner_id =
383 acpi_gbl_root_table_list.tables[table_index].owner_id;
384 } else {
385 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 return;
387 }
388
Len Brown4be44fc2005-08-05 00:44:28 -0400389 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Mooref3d2e782007-02-02 19:48:18 +0300390 acpi_ns_delete_namespace_by_owner(owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391}
392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393/*******************************************************************************
394 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300395 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300397 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300399 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300401 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 *
403 ******************************************************************************/
404
Bob Mooref3d2e782007-02-02 19:48:18 +0300405acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406{
Bob Mooref3d2e782007-02-02 19:48:18 +0300407 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408
Bob Mooref3d2e782007-02-02 19:48:18 +0300409 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
Bob Mooref3d2e782007-02-02 19:48:18 +0300411 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
412 if (table_index < acpi_gbl_root_table_list.count) {
413 status = acpi_ut_allocate_owner_id
414 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 }
416
Bob Mooref3d2e782007-02-02 19:48:18 +0300417 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
418 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419}
420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421/*******************************************************************************
422 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300423 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300425 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300427 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300429 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 *
431 ******************************************************************************/
432
Bob Mooref3d2e782007-02-02 19:48:18 +0300433acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
Bob Mooref3d2e782007-02-02 19:48:18 +0300435 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
Bob Mooref3d2e782007-02-02 19:48:18 +0300437 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Bob Mooref3d2e782007-02-02 19:48:18 +0300439 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
440 if (table_index < acpi_gbl_root_table_list.count) {
441 acpi_ut_release_owner_id(&
442 (acpi_gbl_root_table_list.
443 tables[table_index].owner_id));
444 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 }
446
Bob Mooref3d2e782007-02-02 19:48:18 +0300447 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
448 return_ACPI_STATUS(status);
449}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bob Mooref3d2e782007-02-02 19:48:18 +0300451/*******************************************************************************
452 *
453 * FUNCTION: acpi_tb_get_owner_id
454 *
455 * PARAMETERS: table_index - Table index
456 * owner_id - Where the table owner_id is returned
457 *
458 * RETURN: Status
459 *
460 * DESCRIPTION: returns owner_id for the ACPI table
461 *
462 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463
Bob Mooref3d2e782007-02-02 19:48:18 +0300464acpi_status
465acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id)
466{
467 acpi_status status = AE_BAD_PARAMETER;
468
469 ACPI_FUNCTION_TRACE(tb_get_owner_id);
470
471 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
472 if (table_index < acpi_gbl_root_table_list.count) {
473 *owner_id =
474 acpi_gbl_root_table_list.tables[table_index].owner_id;
475 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 }
477
Bob Mooref3d2e782007-02-02 19:48:18 +0300478 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
479 return_ACPI_STATUS(status);
480}
481
482/*******************************************************************************
483 *
484 * FUNCTION: acpi_tb_is_table_loaded
485 *
486 * PARAMETERS: table_index - Table index
487 *
488 * RETURN: Table Loaded Flag
489 *
490 ******************************************************************************/
491
492u8 acpi_tb_is_table_loaded(acpi_native_uint table_index)
493{
494 u8 is_loaded = FALSE;
495
496 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
497 if (table_index < acpi_gbl_root_table_list.count) {
498 is_loaded = (u8)
499 (acpi_gbl_root_table_list.tables[table_index].
500 flags & ACPI_TABLE_FLAGS_LOADED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 }
502
Bob Mooref3d2e782007-02-02 19:48:18 +0300503 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
504 return (is_loaded);
505}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
Bob Mooref3d2e782007-02-02 19:48:18 +0300507/*******************************************************************************
508 *
509 * FUNCTION: acpi_tb_set_table_loaded_flag
510 *
511 * PARAMETERS: table_index - Table index
512 * is_loaded - TRUE if table is loaded, FALSE otherwise
513 *
514 * RETURN: None
515 *
516 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
517 *
518 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Bob Mooref3d2e782007-02-02 19:48:18 +0300520void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded)
521{
Bob Mooref6dd9222006-07-07 20:44:38 -0400522
Bob Mooref3d2e782007-02-02 19:48:18 +0300523 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
524 if (table_index < acpi_gbl_root_table_list.count) {
525 if (is_loaded) {
526 acpi_gbl_root_table_list.tables[table_index].flags |=
527 ACPI_TABLE_FLAGS_LOADED;
528 } else {
529 acpi_gbl_root_table_list.tables[table_index].flags &=
530 ~ACPI_TABLE_FLAGS_LOADED;
531 }
532 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400533
Bob Mooref3d2e782007-02-02 19:48:18 +0300534 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535}