blob: 5336ce88f89f74b47790be39ceadabd8a5b345b3 [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
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
Bob Moorebc45b1d2008-06-10 14:12:50 +0800126 /*
127 * Originally, we checked the table signature for "SSDT" or "PSDT" here.
128 * Next, we added support for OEMx tables, signature "OEM".
129 * Valid tables were encountered with a null signature, so we've just
130 * given up on validating the signature, since it seems to be a waste
131 * of code. The original code was removed (05/2008).
132 */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300133
Bob Mooref3d2e782007-02-02 19:48:18 +0300134 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Bob Mooref3d2e782007-02-02 19:48:18 +0300136 /* Check if table is already registered */
137
138 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
139 if (!acpi_gbl_root_table_list.tables[i].pointer) {
140 status =
141 acpi_tb_verify_table(&acpi_gbl_root_table_list.
142 tables[i]);
143 if (ACPI_FAILURE(status)
144 || !acpi_gbl_root_table_list.tables[i].pointer) {
145 continue;
146 }
147 }
148
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300149 length = ACPI_MIN(table_desc->length,
150 acpi_gbl_root_table_list.tables[i].length);
151 if (ACPI_MEMCMP(table_desc->pointer,
152 acpi_gbl_root_table_list.tables[i].pointer,
153 length)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300154 continue;
155 }
156
157 /* Table is already registered */
158
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300159 acpi_tb_delete_table(table_desc);
Bob Mooref3d2e782007-02-02 19:48:18 +0300160 *table_index = i;
Lin Ming200cce62008-04-10 19:06:42 +0400161 status = AE_ALREADY_EXISTS;
Bob Mooref3d2e782007-02-02 19:48:18 +0300162 goto release;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 }
164
Robert Moore0c9938c2005-07-29 15:15:00 -0700165 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300166 * Add the table to the global table list
Robert Moore0c9938c2005-07-29 15:15:00 -0700167 */
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300168 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
169 table_desc->length, table_desc->flags,
170 table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400171 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300172 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700173 }
174
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300175 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Bob Mooref3d2e782007-02-02 19:48:18 +0300177 release:
Len Brown4be44fc2005-08-05 00:44:28 -0400178 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
179 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180}
181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182/*******************************************************************************
183 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300184 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300186 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 *
188 * RETURN: Status
189 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300190 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 *
192 ******************************************************************************/
193
Bob Mooref3d2e782007-02-02 19:48:18 +0300194acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
Bob Mooref3d2e782007-02-02 19:48:18 +0300196 struct acpi_table_desc *tables;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Bob Mooref3d2e782007-02-02 19:48:18 +0300198 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Bob Mooref3d2e782007-02-02 19:48:18 +0300200 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Bob Moorec5fc42a2007-02-02 19:48:19 +0300202 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300203 ACPI_ERROR((AE_INFO,
204 "Resize of Root Table Array is not allowed"));
205 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 }
207
Bob Mooref3d2e782007-02-02 19:48:18 +0300208 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
Bob Mooref3d2e782007-02-02 19:48:18 +0300210 tables = ACPI_ALLOCATE_ZEROED((acpi_gbl_root_table_list.size +
211 ACPI_ROOT_TABLE_SIZE_INCREMENT)
212 * sizeof(struct acpi_table_desc));
213 if (!tables) {
214 ACPI_ERROR((AE_INFO,
215 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400216 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 }
218
Bob Mooref3d2e782007-02-02 19:48:18 +0300219 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400220
Bob Mooref3d2e782007-02-02 19:48:18 +0300221 if (acpi_gbl_root_table_list.tables) {
222 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
223 acpi_gbl_root_table_list.size *
224 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400225
Bob Moorec5fc42a2007-02-02 19:48:19 +0300226 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300227 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 }
229 }
230
Bob Mooref3d2e782007-02-02 19:48:18 +0300231 acpi_gbl_root_table_list.tables = tables;
232 acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
Bob Moorec5fc42a2007-02-02 19:48:19 +0300233 acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
Len Brown4be44fc2005-08-05 00:44:28 -0400235 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236}
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238/*******************************************************************************
239 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300240 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300242 * PARAMETERS: Address - Table address
243 * Table - Table header
244 * Length - Table length
245 * Flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300247 * RETURN: Status and table index.
248 *
249 * DESCRIPTION: Add an ACPI table to the global table list
250 *
251 ******************************************************************************/
252
253acpi_status
254acpi_tb_store_table(acpi_physical_address address,
255 struct acpi_table_header *table,
256 u32 length, u8 flags, acpi_native_uint * table_index)
257{
258 acpi_status status = AE_OK;
259
260 /* Ensure that there is room for the table in the Root Table List */
261
262 if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) {
263 status = acpi_tb_resize_root_table_list();
264 if (ACPI_FAILURE(status)) {
265 return (status);
266 }
267 }
268
269 /* Initialize added table */
270
271 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
272 address = address;
273 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
274 pointer = table;
275 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length =
276 length;
277 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].
278 owner_id = 0;
279 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags =
280 flags;
281
282 ACPI_MOVE_32_TO_32(&
283 (acpi_gbl_root_table_list.
284 tables[acpi_gbl_root_table_list.count].signature),
285 table->signature);
286
287 *table_index = acpi_gbl_root_table_list.count;
288 acpi_gbl_root_table_list.count++;
289 return (status);
290}
291
292/*******************************************************************************
293 *
294 * FUNCTION: acpi_tb_delete_table
295 *
296 * PARAMETERS: table_index - Table index
297 *
298 * RETURN: None
299 *
300 * DESCRIPTION: Delete one internal ACPI table
301 *
302 ******************************************************************************/
303
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300304void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
Bob Mooref3d2e782007-02-02 19:48:18 +0300305{
Bob Mooref3d2e782007-02-02 19:48:18 +0300306 /* Table must be mapped or allocated */
Bob Mooref3d2e782007-02-02 19:48:18 +0300307 if (!table_desc->pointer) {
308 return;
309 }
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300310 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
311 case ACPI_TABLE_ORIGIN_MAPPED:
312 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
313 break;
314 case ACPI_TABLE_ORIGIN_ALLOCATED:
Bob Mooref3d2e782007-02-02 19:48:18 +0300315 ACPI_FREE(table_desc->pointer);
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300316 break;
317 default:;
Bob Mooref3d2e782007-02-02 19:48:18 +0300318 }
319
320 table_desc->pointer = NULL;
321}
322
323/*******************************************************************************
324 *
325 * FUNCTION: acpi_tb_terminate
326 *
327 * PARAMETERS: None
328 *
329 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 *
331 * DESCRIPTION: Delete all internal ACPI tables
332 *
333 ******************************************************************************/
334
Bob Mooref3d2e782007-02-02 19:48:18 +0300335void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336{
Bob Mooref3d2e782007-02-02 19:48:18 +0300337 acpi_native_uint i;
338
339 ACPI_FUNCTION_TRACE(tb_terminate);
340
341 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
342
343 /* Delete the individual tables */
344
345 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300346 acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
Bob Mooref3d2e782007-02-02 19:48:18 +0300347 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348
349 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300350 * Delete the root table array if allocated locally. Array cannot be
351 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300353 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300354 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300356
357 acpi_gbl_root_table_list.tables = NULL;
358 acpi_gbl_root_table_list.flags = 0;
359 acpi_gbl_root_table_list.count = 0;
360
361 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
362 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363}
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365/*******************************************************************************
366 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300367 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300369 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300371 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300373 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 *
375 ******************************************************************************/
376
Bob Mooref3d2e782007-02-02 19:48:18 +0300377void acpi_tb_delete_namespace_by_owner(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378{
Bob Mooref3d2e782007-02-02 19:48:18 +0300379 acpi_owner_id owner_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
Bob Mooref3d2e782007-02-02 19:48:18 +0300381 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
382 if (table_index < acpi_gbl_root_table_list.count) {
383 owner_id =
384 acpi_gbl_root_table_list.tables[table_index].owner_id;
385 } else {
386 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 return;
388 }
389
Len Brown4be44fc2005-08-05 00:44:28 -0400390 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Mooref3d2e782007-02-02 19:48:18 +0300391 acpi_ns_delete_namespace_by_owner(owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392}
393
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394/*******************************************************************************
395 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300396 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300398 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300400 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300402 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 *
404 ******************************************************************************/
405
Bob Mooref3d2e782007-02-02 19:48:18 +0300406acpi_status acpi_tb_allocate_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
Bob Mooref3d2e782007-02-02 19:48:18 +0300408 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
Bob Mooref3d2e782007-02-02 19:48:18 +0300410 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
Bob Mooref3d2e782007-02-02 19:48:18 +0300412 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
413 if (table_index < acpi_gbl_root_table_list.count) {
414 status = acpi_ut_allocate_owner_id
415 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 }
417
Bob Mooref3d2e782007-02-02 19:48:18 +0300418 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
419 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420}
421
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422/*******************************************************************************
423 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300424 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300426 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300428 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300430 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 *
432 ******************************************************************************/
433
Bob Mooref3d2e782007-02-02 19:48:18 +0300434acpi_status acpi_tb_release_owner_id(acpi_native_uint table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435{
Bob Mooref3d2e782007-02-02 19:48:18 +0300436 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Bob Mooref3d2e782007-02-02 19:48:18 +0300438 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Bob Mooref3d2e782007-02-02 19:48:18 +0300440 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
441 if (table_index < acpi_gbl_root_table_list.count) {
442 acpi_ut_release_owner_id(&
443 (acpi_gbl_root_table_list.
444 tables[table_index].owner_id));
445 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 }
447
Bob Mooref3d2e782007-02-02 19:48:18 +0300448 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
449 return_ACPI_STATUS(status);
450}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
Bob Mooref3d2e782007-02-02 19:48:18 +0300452/*******************************************************************************
453 *
454 * FUNCTION: acpi_tb_get_owner_id
455 *
456 * PARAMETERS: table_index - Table index
457 * owner_id - Where the table owner_id is returned
458 *
459 * RETURN: Status
460 *
461 * DESCRIPTION: returns owner_id for the ACPI table
462 *
463 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
Bob Mooref3d2e782007-02-02 19:48:18 +0300465acpi_status
466acpi_tb_get_owner_id(acpi_native_uint table_index, acpi_owner_id * owner_id)
467{
468 acpi_status status = AE_BAD_PARAMETER;
469
470 ACPI_FUNCTION_TRACE(tb_get_owner_id);
471
472 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
473 if (table_index < acpi_gbl_root_table_list.count) {
474 *owner_id =
475 acpi_gbl_root_table_list.tables[table_index].owner_id;
476 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 }
478
Bob Mooref3d2e782007-02-02 19:48:18 +0300479 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
480 return_ACPI_STATUS(status);
481}
482
483/*******************************************************************************
484 *
485 * FUNCTION: acpi_tb_is_table_loaded
486 *
487 * PARAMETERS: table_index - Table index
488 *
489 * RETURN: Table Loaded Flag
490 *
491 ******************************************************************************/
492
493u8 acpi_tb_is_table_loaded(acpi_native_uint table_index)
494{
495 u8 is_loaded = FALSE;
496
497 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
498 if (table_index < acpi_gbl_root_table_list.count) {
499 is_loaded = (u8)
500 (acpi_gbl_root_table_list.tables[table_index].
Bob Moorec5fc42a2007-02-02 19:48:19 +0300501 flags & ACPI_TABLE_IS_LOADED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 }
503
Bob Mooref3d2e782007-02-02 19:48:18 +0300504 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
505 return (is_loaded);
506}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
Bob Mooref3d2e782007-02-02 19:48:18 +0300508/*******************************************************************************
509 *
510 * FUNCTION: acpi_tb_set_table_loaded_flag
511 *
512 * PARAMETERS: table_index - Table index
513 * is_loaded - TRUE if table is loaded, FALSE otherwise
514 *
515 * RETURN: None
516 *
517 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
518 *
519 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
Bob Mooref3d2e782007-02-02 19:48:18 +0300521void acpi_tb_set_table_loaded_flag(acpi_native_uint table_index, u8 is_loaded)
522{
Bob Mooref6dd9222006-07-07 20:44:38 -0400523
Bob Mooref3d2e782007-02-02 19:48:18 +0300524 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
525 if (table_index < acpi_gbl_root_table_list.count) {
526 if (is_loaded) {
527 acpi_gbl_root_table_list.tables[table_index].flags |=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300528 ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300529 } else {
530 acpi_gbl_root_table_list.tables[table_index].flags &=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300531 ~ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300532 }
533 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400534
Bob Mooref3d2e782007-02-02 19:48:18 +0300535 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536}