blob: 9e0b3ce0d8e572985065cee2ef2310b0bf3acb41 [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 Moorec5fc42a2007-02-02 19:48:19 +030064 acpi_status status;
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
Bob Moorec5fc42a2007-02-02 19:48:19 +030087 status =
88 acpi_tb_verify_checksum(table_desc->pointer, table_desc->length);
89 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092/*******************************************************************************
93 *
Bob Mooref3d2e782007-02-02 19:48:18 +030094 * FUNCTION: acpi_tb_add_table
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 *
Bob Mooref3d2e782007-02-02 19:48:18 +030096 * PARAMETERS: Table - Pointer to the table header
97 * table_index - Where the table index is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 *
99 * RETURN: Status
100 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300101 * DESCRIPTION: This function is called to add the ACPI table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *
103 ******************************************************************************/
104
Bob Mooref3d2e782007-02-02 19:48:18 +0300105acpi_status
106acpi_tb_add_table(struct acpi_table_header *table,
107 acpi_native_uint * table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108{
Bob Mooref3d2e782007-02-02 19:48:18 +0300109 acpi_native_uint i;
110 acpi_native_uint length;
111 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Bob Mooref3d2e782007-02-02 19:48:18 +0300113 ACPI_FUNCTION_TRACE(tb_add_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Bob Mooref3d2e782007-02-02 19:48:18 +0300115 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Bob Mooref3d2e782007-02-02 19:48:18 +0300117 /* Check if table is already registered */
118
119 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
120 if (!acpi_gbl_root_table_list.tables[i].pointer) {
121 status =
122 acpi_tb_verify_table(&acpi_gbl_root_table_list.
123 tables[i]);
124 if (ACPI_FAILURE(status)
125 || !acpi_gbl_root_table_list.tables[i].pointer) {
126 continue;
127 }
128 }
129
130 length = ACPI_MIN(table->length,
131 acpi_gbl_root_table_list.tables[i].pointer->
132 length);
133 if (ACPI_MEMCMP
134 (table, acpi_gbl_root_table_list.tables[i].pointer,
135 length)) {
136 continue;
137 }
138
139 /* Table is already registered */
140
141 ACPI_FREE(table);
142 *table_index = i;
143 goto release;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 }
145
Robert Moore0c9938c2005-07-29 15:15:00 -0700146 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300147 * Add the table to the global table list
Robert Moore0c9938c2005-07-29 15:15:00 -0700148 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300149 status = acpi_tb_store_table(ACPI_TO_INTEGER(table),
150 table, table->length,
151 ACPI_TABLE_ORIGIN_ALLOCATED, table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400152 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300153 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700154 }
155
Bob Mooref3d2e782007-02-02 19:48:18 +0300156 acpi_tb_print_table_header(0, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Bob Mooref3d2e782007-02-02 19:48:18 +0300158 release:
Len Brown4be44fc2005-08-05 00:44:28 -0400159 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
160 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161}
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163/*******************************************************************************
164 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300165 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300167 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 *
169 * RETURN: Status
170 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300171 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 *
173 ******************************************************************************/
174
Bob Mooref3d2e782007-02-02 19:48:18 +0300175acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176{
Bob Mooref3d2e782007-02-02 19:48:18 +0300177 struct acpi_table_desc *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Bob Mooref3d2e782007-02-02 19:48:18 +0300179 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
Bob Mooref3d2e782007-02-02 19:48:18 +0300181 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Bob Moorec5fc42a2007-02-02 19:48:19 +0300183 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300184 ACPI_ERROR((AE_INFO,
185 "Resize of Root Table Array is not allowed"));
186 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 }
188
Bob Mooref3d2e782007-02-02 19:48:18 +0300189 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Bob Mooref3d2e782007-02-02 19:48:18 +0300191 tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size +
192 ACPI_ROOT_TABLE_SIZE_INCREMENT)
193 * sizeof(struct acpi_table_desc));
194 if (!tables) {
195 ACPI_ERROR((AE_INFO,
196 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400197 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 }
199
Bob Mooref3d2e782007-02-02 19:48:18 +0300200 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400201
Bob Mooref3d2e782007-02-02 19:48:18 +0300202 if (acpi_gbl_root_table_list.tables) {
203 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
204 acpi_gbl_root_table_list.size *
205 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400206
Bob Moorec5fc42a2007-02-02 19:48:19 +0300207 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300208 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 }
210 }
211
Bob Mooref3d2e782007-02-02 19:48:18 +0300212 acpi_gbl_root_table_list.tables = tables;
213 acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
Bob Moorec5fc42a2007-02-02 19:48:19 +0300214 acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
Len Brown4be44fc2005-08-05 00:44:28 -0400216 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217}
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219/*******************************************************************************
220 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300221 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300223 * PARAMETERS: Address - Table address
224 * Table - Table header
225 * Length - Table length
226 * Flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300228 * RETURN: Status and table index.
229 *
230 * DESCRIPTION: Add an ACPI table to the global table list
231 *
232 ******************************************************************************/
233
234acpi_status
235acpi_tb_store_table(acpi_physical_address address,
236 struct acpi_table_header *table,
237 u32 length, u8 flags, acpi_native_uint * table_index)
238{
239 acpi_status status = AE_OK;
240
241 /* Ensure that there is room for the table in the Root Table List */
242
243 if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) {
244 status = acpi_tb_resize_root_table_list();
245 if (ACPI_FAILURE(status)) {
246 return (status);
247 }
248 }
249
250 /* Initialize added table */
251
252 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
253 address = address;
254 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
255 pointer = table;
256 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length =
257 length;
258 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
259 owner_id = 0;
260 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags =
261 flags;
262
263 ACPI_MOVE_32_TO_32(&
264 (acpi_gbl_root_table_list.
265 tables[acpi_gbl_root_table_list.count].signature),
266 table->signature);
267
268 *table_index = acpi_gbl_root_table_list.count;
269 acpi_gbl_root_table_list.count++;
270 return (status);
271}
272
273/*******************************************************************************
274 *
275 * FUNCTION: acpi_tb_delete_table
276 *
277 * PARAMETERS: table_index - Table index
278 *
279 * RETURN: None
280 *
281 * DESCRIPTION: Delete one internal ACPI table
282 *
283 ******************************************************************************/
284
285void acpi_tb_delete_table(acpi_native_uint table_index)
286{
287 struct acpi_table_desc *table_desc;
288
289 /* table_index assumed valid */
290
291 table_desc = &acpi_gbl_root_table_list.tables[table_index];
292
293 /* Table must be mapped or allocated */
294
295 if (!table_desc->pointer) {
296 return;
297 }
298
299 if (table_desc->flags & ACPI_TABLE_ORIGIN_MAPPED) {
300 acpi_tb_unmap(table_desc->pointer, table_desc->length,
301 table_desc->flags & ACPI_TABLE_ORIGIN_MASK);
302 } else if (table_desc->flags & ACPI_TABLE_ORIGIN_ALLOCATED) {
303 ACPI_FREE(table_desc->pointer);
304 }
305
306 table_desc->pointer = NULL;
307}
308
309/*******************************************************************************
310 *
311 * FUNCTION: acpi_tb_terminate
312 *
313 * PARAMETERS: None
314 *
315 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 *
317 * DESCRIPTION: Delete all internal ACPI tables
318 *
319 ******************************************************************************/
320
Bob Mooref3d2e782007-02-02 19:48:18 +0300321void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322{
Bob Mooref3d2e782007-02-02 19:48:18 +0300323 acpi_native_uint i;
324
325 ACPI_FUNCTION_TRACE(tb_terminate);
326
327 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
328
329 /* Delete the individual tables */
330
331 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
332 acpi_tb_delete_table(i);
333 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
335 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300336 * Delete the root table array if allocated locally. Array cannot be
337 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300339 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300340 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300342
343 acpi_gbl_root_table_list.tables = NULL;
344 acpi_gbl_root_table_list.flags = 0;
345 acpi_gbl_root_table_list.count = 0;
346
347 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
348 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349}
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351/*******************************************************************************
352 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300353 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300355 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300357 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300359 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 *
361 ******************************************************************************/
362
Bob Mooref3d2e782007-02-02 19:48:18 +0300363void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
Bob Mooref3d2e782007-02-02 19:48:18 +0300365 acpi_owner_id owner_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
Bob Mooref3d2e782007-02-02 19:48:18 +0300367 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
368 if (table_index < acpi_gbl_root_table_list.count) {
369 owner_id =
370 acpi_gbl_root_table_list.tables[table_index].owner_id;
371 } else {
372 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 return;
374 }
375
Len Brown4be44fc2005-08-05 00:44:28 -0400376 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Mooref3d2e782007-02-02 19:48:18 +0300377 acpi_ns_delete_namespace_by_owner(owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380/*******************************************************************************
381 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300382 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300384 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300386 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300388 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 *
390 ******************************************************************************/
391
Bob Mooref3d2e782007-02-02 19:48:18 +0300392acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
Bob Mooref3d2e782007-02-02 19:48:18 +0300394 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Bob Mooref3d2e782007-02-02 19:48:18 +0300396 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
Bob Mooref3d2e782007-02-02 19:48:18 +0300398 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
399 if (table_index < acpi_gbl_root_table_list.count) {
400 status = acpi_ut_allocate_owner_id
401 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 }
403
Bob Mooref3d2e782007-02-02 19:48:18 +0300404 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
405 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406}
407
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408/*******************************************************************************
409 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300410 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300412 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300414 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300416 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 *
418 ******************************************************************************/
419
Bob Mooref3d2e782007-02-02 19:48:18 +0300420acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
Bob Mooref3d2e782007-02-02 19:48:18 +0300422 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
Bob Mooref3d2e782007-02-02 19:48:18 +0300424 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
Bob Mooref3d2e782007-02-02 19:48:18 +0300426 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
427 if (table_index < acpi_gbl_root_table_list.count) {
428 acpi_ut_release_owner_id(&
429 (acpi_gbl_root_table_list.
430 tables[table_index].owner_id));
431 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 }
433
Bob Mooref3d2e782007-02-02 19:48:18 +0300434 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
435 return_ACPI_STATUS(status);
436}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Bob Mooref3d2e782007-02-02 19:48:18 +0300438/*******************************************************************************
439 *
440 * FUNCTION: acpi_tb_get_owner_id
441 *
442 * PARAMETERS: table_index - Table index
443 * owner_id - Where the table owner_id is returned
444 *
445 * RETURN: Status
446 *
447 * DESCRIPTION: returns owner_id for the ACPI table
448 *
449 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bob Mooref3d2e782007-02-02 19:48:18 +0300451acpi_status
452acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id)
453{
454 acpi_status status = AE_BAD_PARAMETER;
455
456 ACPI_FUNCTION_TRACE(tb_get_owner_id);
457
458 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
459 if (table_index < acpi_gbl_root_table_list.count) {
460 *owner_id =
461 acpi_gbl_root_table_list.tables[table_index].owner_id;
462 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 }
464
Bob Mooref3d2e782007-02-02 19:48:18 +0300465 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
466 return_ACPI_STATUS(status);
467}
468
469/*******************************************************************************
470 *
471 * FUNCTION: acpi_tb_is_table_loaded
472 *
473 * PARAMETERS: table_index - Table index
474 *
475 * RETURN: Table Loaded Flag
476 *
477 ******************************************************************************/
478
479u8 acpi_tb_is_table_loaded(acpi_native_uint table_index)
480{
481 u8 is_loaded = FALSE;
482
483 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
484 if (table_index < acpi_gbl_root_table_list.count) {
485 is_loaded = (u8)
486 (acpi_gbl_root_table_list.tables[table_index].
Bob Moorec5fc42a2007-02-02 19:48:19 +0300487 flags & ACPI_TABLE_IS_LOADED);
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 (is_loaded);
492}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
Bob Mooref3d2e782007-02-02 19:48:18 +0300494/*******************************************************************************
495 *
496 * FUNCTION: acpi_tb_set_table_loaded_flag
497 *
498 * PARAMETERS: table_index - Table index
499 * is_loaded - TRUE if table is loaded, FALSE otherwise
500 *
501 * RETURN: None
502 *
503 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
504 *
505 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
Bob Mooref3d2e782007-02-02 19:48:18 +0300507void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded)
508{
Bob Mooref6dd9222006-07-07 20:44:38 -0400509
Bob Mooref3d2e782007-02-02 19:48:18 +0300510 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
511 if (table_index < acpi_gbl_root_table_list.count) {
512 if (is_loaded) {
513 acpi_gbl_root_table_list.tables[table_index].flags |=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300514 ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300515 } else {
516 acpi_gbl_root_table_list.tables[table_index].flags &=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300517 ~ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300518 }
519 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400520
Bob Mooref3d2e782007-02-02 19:48:18 +0300521 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}