Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: tbxface - Public interfaces to the ACPI subsystem |
| 4 | * ACPI table oriented interfaces |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
Bob Moore | 7784813 | 2012-01-12 13:27:23 +0800 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2012, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
Paul Gortmaker | 214f2c9 | 2011-10-26 16:22:14 -0400 | [diff] [blame] | 45 | #include <linux/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 47 | #include "accommon.h" |
| 48 | #include "acnamesp.h" |
| 49 | #include "actables.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define _COMPONENT ACPI_TABLES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | ACPI_MODULE_NAME("tbxface") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 54 | /* Local prototypes */ |
| 55 | static acpi_status acpi_tb_load_namespace(void); |
| 56 | |
Len Brown | 67effe8 | 2007-07-26 00:50:06 -0400 | [diff] [blame] | 57 | static int no_auto_ssdt; |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | /******************************************************************************* |
| 60 | * |
Bob Moore | 77389e1 | 2007-02-02 19:48:20 +0300 | [diff] [blame] | 61 | * FUNCTION: acpi_allocate_root_table |
| 62 | * |
| 63 | * PARAMETERS: initial_table_count - Size of initial_table_array, in number of |
| 64 | * struct acpi_table_desc structures |
| 65 | * |
| 66 | * RETURN: Status |
| 67 | * |
| 68 | * DESCRIPTION: Allocate a root table array. Used by i_aSL compiler and |
| 69 | * acpi_initialize_tables. |
| 70 | * |
| 71 | ******************************************************************************/ |
| 72 | |
| 73 | acpi_status acpi_allocate_root_table(u32 initial_table_count) |
| 74 | { |
| 75 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 76 | acpi_gbl_root_table_list.max_table_count = initial_table_count; |
Bob Moore | 77389e1 | 2007-02-02 19:48:20 +0300 | [diff] [blame] | 77 | acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE; |
| 78 | |
| 79 | return (acpi_tb_resize_root_table_list()); |
| 80 | } |
| 81 | |
| 82 | /******************************************************************************* |
| 83 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 84 | * FUNCTION: acpi_initialize_tables |
| 85 | * |
| 86 | * PARAMETERS: initial_table_array - Pointer to an array of pre-allocated |
| 87 | * struct acpi_table_desc structures. If NULL, the |
| 88 | * array is dynamically allocated. |
| 89 | * initial_table_count - Size of initial_table_array, in number of |
| 90 | * struct acpi_table_desc structures |
| 91 | * allow_realloc - Flag to tell Table Manager if resize of |
| 92 | * pre-allocated array is allowed. Ignored |
| 93 | * if initial_table_array is NULL. |
| 94 | * |
| 95 | * RETURN: Status |
| 96 | * |
| 97 | * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. |
| 98 | * |
| 99 | * NOTE: Allows static allocation of the initial table array in order |
| 100 | * to avoid the use of dynamic memory in confined environments |
| 101 | * such as the kernel boot sequence where it may not be available. |
| 102 | * |
| 103 | * If the host OS memory managers are initialized, use NULL for |
| 104 | * initial_table_array, and the table will be dynamically allocated. |
| 105 | * |
| 106 | ******************************************************************************/ |
| 107 | |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 108 | acpi_status __init |
Bob Moore | 77389e1 | 2007-02-02 19:48:20 +0300 | [diff] [blame] | 109 | acpi_initialize_tables(struct acpi_table_desc * initial_table_array, |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 110 | u32 initial_table_count, u8 allow_resize) |
| 111 | { |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 112 | acpi_physical_address rsdp_address; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 113 | acpi_status status; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 114 | |
| 115 | ACPI_FUNCTION_TRACE(acpi_initialize_tables); |
| 116 | |
| 117 | /* |
| 118 | * Set up the Root Table Array |
| 119 | * Allocate the table array if requested |
| 120 | */ |
| 121 | if (!initial_table_array) { |
Bob Moore | 77389e1 | 2007-02-02 19:48:20 +0300 | [diff] [blame] | 122 | status = acpi_allocate_root_table(initial_table_count); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 123 | if (ACPI_FAILURE(status)) { |
| 124 | return_ACPI_STATUS(status); |
| 125 | } |
| 126 | } else { |
| 127 | /* Root Table Array has been statically allocated by the host */ |
| 128 | |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 129 | ACPI_MEMSET(initial_table_array, 0, |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 130 | (acpi_size) initial_table_count * |
Bob Moore | a4bbb81 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 131 | sizeof(struct acpi_table_desc)); |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 132 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 133 | acpi_gbl_root_table_list.tables = initial_table_array; |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 134 | acpi_gbl_root_table_list.max_table_count = initial_table_count; |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 135 | acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 136 | if (allow_resize) { |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 137 | acpi_gbl_root_table_list.flags |= |
| 138 | ACPI_ROOT_ALLOW_RESIZE; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 142 | /* Get the address of the RSDP */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 143 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 144 | rsdp_address = acpi_os_get_root_pointer(); |
| 145 | if (!rsdp_address) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 146 | return_ACPI_STATUS(AE_NOT_FOUND); |
| 147 | } |
| 148 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 149 | /* |
| 150 | * Get the root table (RSDT or XSDT) and extract all entries to the local |
| 151 | * Root Table Array. This array contains the information of the RSDT/XSDT |
| 152 | * in a common, more useable format. |
| 153 | */ |
Bob Moore | 97cbb7d | 2009-02-03 14:41:03 +0800 | [diff] [blame] | 154 | status = acpi_tb_parse_root_table(rsdp_address); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 155 | return_ACPI_STATUS(status); |
| 156 | } |
| 157 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 158 | /******************************************************************************* |
| 159 | * |
| 160 | * FUNCTION: acpi_reallocate_root_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | * |
| 162 | * PARAMETERS: None |
| 163 | * |
| 164 | * RETURN: Status |
| 165 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 166 | * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the |
| 167 | * root list from the previously provided scratch area. Should |
| 168 | * be called once dynamic memory allocation is available in the |
| 169 | * kernel |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | * |
| 171 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 172 | acpi_status acpi_reallocate_root_table(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 174 | struct acpi_table_desc *tables; |
| 175 | acpi_size new_size; |
Alexey Starikovskiy | 333b04a | 2010-04-01 11:06:34 +0800 | [diff] [blame] | 176 | acpi_size current_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 178 | ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 180 | /* |
| 181 | * Only reallocate the root table if the host provided a static buffer |
| 182 | * for the table array in the call to acpi_initialize_tables. |
| 183 | */ |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 184 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 185 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Alexey Starikovskiy | 333b04a | 2010-04-01 11:06:34 +0800 | [diff] [blame] | 188 | /* |
| 189 | * Get the current size of the root table and add the default |
| 190 | * increment to create the new table size. |
| 191 | */ |
| 192 | current_size = (acpi_size) |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 193 | acpi_gbl_root_table_list.current_table_count * |
| 194 | sizeof(struct acpi_table_desc); |
Alexey Starikovskiy | 333b04a | 2010-04-01 11:06:34 +0800 | [diff] [blame] | 195 | |
| 196 | new_size = current_size + |
| 197 | (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof(struct acpi_table_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 199 | /* Create new array and copy the old array */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 201 | tables = ACPI_ALLOCATE_ZEROED(new_size); |
| 202 | if (!tables) { |
| 203 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Alexey Starikovskiy | 333b04a | 2010-04-01 11:06:34 +0800 | [diff] [blame] | 206 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, current_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
Alexey Starikovskiy | 333b04a | 2010-04-01 11:06:34 +0800 | [diff] [blame] | 208 | /* |
| 209 | * Update the root table descriptor. The new size will be the current |
| 210 | * number of tables plus the increment, independent of the reserved |
| 211 | * size of the original table list. |
| 212 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 213 | acpi_gbl_root_table_list.tables = tables; |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 214 | acpi_gbl_root_table_list.max_table_count = |
| 215 | acpi_gbl_root_table_list.current_table_count + |
| 216 | ACPI_ROOT_TABLE_SIZE_INCREMENT; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 217 | acpi_gbl_root_table_list.flags = |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 218 | ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 220 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | } |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 222 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | /******************************************************************************* |
| 224 | * |
| 225 | * FUNCTION: acpi_load_table |
| 226 | * |
| 227 | * PARAMETERS: table_ptr - pointer to a buffer containing the entire |
| 228 | * table to be loaded |
| 229 | * |
| 230 | * RETURN: Status |
| 231 | * |
| 232 | * DESCRIPTION: This function is called to load a table from the caller's |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 233 | * buffer. The buffer must contain an entire ACPI Table including |
| 234 | * a valid header. The header fields will be verified, and if it |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | * is determined that the table is invalid, the call will fail. |
| 236 | * |
| 237 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 238 | acpi_status acpi_load_table(struct acpi_table_header *table_ptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | acpi_status status; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 241 | u32 table_index; |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 242 | struct acpi_table_desc table_desc; |
| 243 | |
| 244 | if (!table_ptr) |
| 245 | return AE_BAD_PARAMETER; |
| 246 | |
| 247 | ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc)); |
| 248 | table_desc.pointer = table_ptr; |
| 249 | table_desc.length = table_ptr->length; |
| 250 | table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 252 | /* |
| 253 | * Install the new table into the local data structures |
| 254 | */ |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 255 | status = acpi_tb_add_table(&table_desc, &table_index); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 256 | if (ACPI_FAILURE(status)) { |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 257 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 259 | status = acpi_ns_load_table(table_index, acpi_gbl_root_node); |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 260 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 263 | ACPI_EXPORT_SYMBOL(acpi_load_table) |
| 264 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 265 | /******************************************************************************* |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 266 | * |
| 267 | * FUNCTION: acpi_get_table_header |
| 268 | * |
| 269 | * PARAMETERS: Signature - ACPI signature of needed table |
| 270 | * Instance - Which instance (for SSDTs) |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 271 | * out_table_header - The pointer to the table header to fill |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 272 | * |
| 273 | * RETURN: Status and pointer to mapped table header |
| 274 | * |
| 275 | * DESCRIPTION: Finds an ACPI table header. |
| 276 | * |
| 277 | * NOTE: Caller is responsible in unmapping the header with |
| 278 | * acpi_os_unmap_memory |
| 279 | * |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 280 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 281 | acpi_status |
| 282 | acpi_get_table_header(char *signature, |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 283 | u32 instance, struct acpi_table_header *out_table_header) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 284 | { |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 285 | u32 i; |
| 286 | u32 j; |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 287 | struct acpi_table_header *header; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 288 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 289 | /* Parameter validation */ |
| 290 | |
| 291 | if (!signature || !out_table_header) { |
| 292 | return (AE_BAD_PARAMETER); |
| 293 | } |
| 294 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 295 | /* Walk the root table list */ |
| 296 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 297 | for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count; |
| 298 | i++) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 299 | if (!ACPI_COMPARE_NAME |
| 300 | (&(acpi_gbl_root_table_list.tables[i].signature), |
| 301 | signature)) { |
| 302 | continue; |
| 303 | } |
| 304 | |
| 305 | if (++j < instance) { |
| 306 | continue; |
| 307 | } |
| 308 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 309 | if (!acpi_gbl_root_table_list.tables[i].pointer) { |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 310 | if ((acpi_gbl_root_table_list.tables[i].flags & |
| 311 | ACPI_TABLE_ORIGIN_MASK) == |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 312 | ACPI_TABLE_ORIGIN_MAPPED) { |
| 313 | header = |
| 314 | acpi_os_map_memory(acpi_gbl_root_table_list. |
| 315 | tables[i].address, |
| 316 | sizeof(struct |
| 317 | acpi_table_header)); |
| 318 | if (!header) { |
| 319 | return AE_NO_MEMORY; |
| 320 | } |
| 321 | ACPI_MEMCPY(out_table_header, header, |
| 322 | sizeof(struct acpi_table_header)); |
| 323 | acpi_os_unmap_memory(header, |
| 324 | sizeof(struct |
| 325 | acpi_table_header)); |
| 326 | } else { |
| 327 | return AE_NOT_FOUND; |
| 328 | } |
| 329 | } else { |
| 330 | ACPI_MEMCPY(out_table_header, |
| 331 | acpi_gbl_root_table_list.tables[i].pointer, |
| 332 | sizeof(struct acpi_table_header)); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 333 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 334 | return (AE_OK); |
| 335 | } |
| 336 | |
| 337 | return (AE_NOT_FOUND); |
| 338 | } |
| 339 | |
| 340 | ACPI_EXPORT_SYMBOL(acpi_get_table_header) |
| 341 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 342 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | * |
John Keller | 0f0fe1a | 2006-12-19 12:56:19 -0800 | [diff] [blame] | 344 | * FUNCTION: acpi_unload_table_id |
| 345 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 346 | * PARAMETERS: id - Owner ID of the table to be removed. |
John Keller | 0f0fe1a | 2006-12-19 12:56:19 -0800 | [diff] [blame] | 347 | * |
| 348 | * RETURN: Status |
| 349 | * |
| 350 | * DESCRIPTION: This routine is used to force the unload of a table (by id) |
| 351 | * |
| 352 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 353 | acpi_status acpi_unload_table_id(acpi_owner_id id) |
John Keller | 0f0fe1a | 2006-12-19 12:56:19 -0800 | [diff] [blame] | 354 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 355 | int i; |
| 356 | acpi_status status = AE_NOT_EXIST; |
John Keller | 0f0fe1a | 2006-12-19 12:56:19 -0800 | [diff] [blame] | 357 | |
John Keller | ecb5f75 | 2007-02-15 14:08:30 -0600 | [diff] [blame] | 358 | ACPI_FUNCTION_TRACE(acpi_unload_table_id); |
John Keller | 0f0fe1a | 2006-12-19 12:56:19 -0800 | [diff] [blame] | 359 | |
John Keller | ecb5f75 | 2007-02-15 14:08:30 -0600 | [diff] [blame] | 360 | /* Find table in the global table list */ |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 361 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 362 | if (id != acpi_gbl_root_table_list.tables[i].owner_id) { |
| 363 | continue; |
| 364 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | /* |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 366 | * Delete all namespace objects owned by this table. Note that these |
| 367 | * objects can appear anywhere in the namespace by virtue of the AML |
| 368 | * "Scope" operator. Thus, we need to track ownership by an ID, not |
| 369 | * simply a position within the hierarchy |
| 370 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 371 | acpi_tb_delete_namespace_by_owner(i); |
John Keller | ecb5f75 | 2007-02-15 14:08:30 -0600 | [diff] [blame] | 372 | status = acpi_tb_release_owner_id(i); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 373 | acpi_tb_set_table_loaded_flag(i, FALSE); |
John Keller | ecb5f75 | 2007-02-15 14:08:30 -0600 | [diff] [blame] | 374 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 376 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
| 378 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 379 | ACPI_EXPORT_SYMBOL(acpi_unload_table_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
| 381 | /******************************************************************************* |
| 382 | * |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 383 | * FUNCTION: acpi_get_table_with_size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 385 | * PARAMETERS: Signature - ACPI signature of needed table |
| 386 | * Instance - Which instance (for SSDTs) |
| 387 | * out_table - Where the pointer to the table is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 389 | * RETURN: Status and pointer to table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 391 | * DESCRIPTION: Finds and verifies an ACPI table. |
| 392 | * |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 393 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 394 | acpi_status |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 395 | acpi_get_table_with_size(char *signature, |
| 396 | u32 instance, struct acpi_table_header **out_table, |
| 397 | acpi_size *tbl_size) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 398 | { |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 399 | u32 i; |
| 400 | u32 j; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 401 | acpi_status status; |
| 402 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 403 | /* Parameter validation */ |
| 404 | |
| 405 | if (!signature || !out_table) { |
| 406 | return (AE_BAD_PARAMETER); |
| 407 | } |
| 408 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 409 | /* Walk the root table list */ |
| 410 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 411 | for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count; |
| 412 | i++) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 413 | if (!ACPI_COMPARE_NAME |
| 414 | (&(acpi_gbl_root_table_list.tables[i].signature), |
| 415 | signature)) { |
| 416 | continue; |
| 417 | } |
| 418 | |
| 419 | if (++j < instance) { |
| 420 | continue; |
| 421 | } |
| 422 | |
| 423 | status = |
| 424 | acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]); |
| 425 | if (ACPI_SUCCESS(status)) { |
| 426 | *out_table = acpi_gbl_root_table_list.tables[i].pointer; |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 427 | *tbl_size = acpi_gbl_root_table_list.tables[i].length; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 428 | } |
| 429 | |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 430 | if (!acpi_gbl_permanent_mmap) { |
Randy Dunlap | 70c0846 | 2007-02-13 16:11:36 -0800 | [diff] [blame] | 431 | acpi_gbl_root_table_list.tables[i].pointer = NULL; |
Alexey Starikovskiy | ad71860a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 432 | } |
| 433 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 434 | return (status); |
| 435 | } |
| 436 | |
| 437 | return (AE_NOT_FOUND); |
| 438 | } |
| 439 | |
Yinghai Lu | 7d97277 | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 440 | acpi_status |
| 441 | acpi_get_table(char *signature, |
| 442 | u32 instance, struct acpi_table_header **out_table) |
| 443 | { |
| 444 | acpi_size tbl_size; |
| 445 | |
| 446 | return acpi_get_table_with_size(signature, |
| 447 | instance, out_table, &tbl_size); |
| 448 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 449 | ACPI_EXPORT_SYMBOL(acpi_get_table) |
| 450 | |
| 451 | /******************************************************************************* |
| 452 | * |
| 453 | * FUNCTION: acpi_get_table_by_index |
| 454 | * |
| 455 | * PARAMETERS: table_index - Table index |
| 456 | * Table - Where the pointer to the table is returned |
| 457 | * |
| 458 | * RETURN: Status and pointer to the table |
| 459 | * |
| 460 | * DESCRIPTION: Obtain a table by an index into the global table list. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | * |
| 462 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | acpi_status |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 464 | acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 466 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 468 | ACPI_FUNCTION_TRACE(acpi_get_table_by_index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 470 | /* Parameter validation */ |
| 471 | |
| 472 | if (!table) { |
| 473 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 474 | } |
| 475 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 476 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 478 | /* Validate index */ |
| 479 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 480 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 481 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 482 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 485 | if (!acpi_gbl_root_table_list.tables[table_index].pointer) { |
| 486 | |
| 487 | /* Table is not mapped, map it */ |
| 488 | |
| 489 | status = |
| 490 | acpi_tb_verify_table(&acpi_gbl_root_table_list. |
| 491 | tables[table_index]); |
| 492 | if (ACPI_FAILURE(status)) { |
| 493 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 494 | return_ACPI_STATUS(status); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | *table = acpi_gbl_root_table_list.tables[table_index].pointer; |
| 499 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 500 | return_ACPI_STATUS(AE_OK); |
| 501 | } |
| 502 | |
| 503 | ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) |
| 504 | |
| 505 | /******************************************************************************* |
| 506 | * |
| 507 | * FUNCTION: acpi_tb_load_namespace |
| 508 | * |
| 509 | * PARAMETERS: None |
| 510 | * |
| 511 | * RETURN: Status |
| 512 | * |
| 513 | * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in |
| 514 | * the RSDT/XSDT. |
| 515 | * |
| 516 | ******************************************************************************/ |
| 517 | static acpi_status acpi_tb_load_namespace(void) |
| 518 | { |
| 519 | acpi_status status; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 520 | u32 i; |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 521 | struct acpi_table_header *new_dsdt; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 522 | |
| 523 | ACPI_FUNCTION_TRACE(tb_load_namespace); |
| 524 | |
| 525 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 526 | |
| 527 | /* |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 528 | * Load the namespace. The DSDT is required, but any SSDT and |
| 529 | * PSDT tables are optional. Verify the DSDT. |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 530 | */ |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 531 | if (!acpi_gbl_root_table_list.current_table_count || |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 532 | !ACPI_COMPARE_NAME(& |
| 533 | (acpi_gbl_root_table_list. |
| 534 | tables[ACPI_TABLE_INDEX_DSDT].signature), |
| 535 | ACPI_SIG_DSDT) |
| 536 | || |
| 537 | ACPI_FAILURE(acpi_tb_verify_table |
| 538 | (&acpi_gbl_root_table_list. |
| 539 | tables[ACPI_TABLE_INDEX_DSDT]))) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 540 | status = AE_NO_ACPI_TABLES; |
| 541 | goto unlock_and_exit; |
| 542 | } |
| 543 | |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 544 | /* |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 545 | * Save the DSDT pointer for simple access. This is the mapped memory |
| 546 | * address. We must take care here because the address of the .Tables |
| 547 | * array can change dynamically as tables are loaded at run-time. Note: |
| 548 | * .Pointer field is not validated until after call to acpi_tb_verify_table. |
| 549 | */ |
| 550 | acpi_gbl_DSDT = |
| 551 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer; |
| 552 | |
| 553 | /* |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 554 | * Optionally copy the entire DSDT to local memory (instead of simply |
| 555 | * mapping it.) There are some BIOSs that corrupt or replace the original |
| 556 | * DSDT, creating the need for this option. Default is FALSE, do not copy |
| 557 | * the DSDT. |
| 558 | */ |
| 559 | if (acpi_gbl_copy_dsdt_locally) { |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 560 | new_dsdt = acpi_tb_copy_dsdt(ACPI_TABLE_INDEX_DSDT); |
| 561 | if (new_dsdt) { |
| 562 | acpi_gbl_DSDT = new_dsdt; |
| 563 | } |
Lin Ming | 69ec87e | 2010-04-01 11:14:12 +0800 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /* |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 567 | * Save the original DSDT header for detection of table corruption |
| 568 | * and/or replacement of the DSDT from outside the OS. |
| 569 | */ |
Bob Moore | 43323cb | 2010-04-07 11:05:11 +0800 | [diff] [blame] | 570 | ACPI_MEMCPY(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT, |
Lin Ming | 729df0f | 2010-04-01 10:47:56 +0800 | [diff] [blame] | 571 | sizeof(struct acpi_table_header)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 573 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 575 | /* Load and parse tables */ |
| 576 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 577 | status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 578 | if (ACPI_FAILURE(status)) { |
| 579 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 582 | /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ |
| 583 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 584 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 585 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 586 | if ((!ACPI_COMPARE_NAME |
| 587 | (&(acpi_gbl_root_table_list.tables[i].signature), |
| 588 | ACPI_SIG_SSDT) |
| 589 | && |
| 590 | !ACPI_COMPARE_NAME(& |
| 591 | (acpi_gbl_root_table_list.tables[i]. |
| 592 | signature), ACPI_SIG_PSDT)) |
| 593 | || |
| 594 | ACPI_FAILURE(acpi_tb_verify_table |
| 595 | (&acpi_gbl_root_table_list.tables[i]))) { |
| 596 | continue; |
| 597 | } |
| 598 | |
Len Brown | 67effe8 | 2007-07-26 00:50:06 -0400 | [diff] [blame] | 599 | if (no_auto_ssdt) { |
| 600 | printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); |
| 601 | continue; |
| 602 | } |
| 603 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 604 | /* Ignore errors while loading tables, get as many as possible */ |
| 605 | |
| 606 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 607 | (void)acpi_ns_load_table(i, acpi_gbl_root_node); |
| 608 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | } |
| 610 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 611 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 613 | unlock_and_exit: |
| 614 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 615 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 618 | /******************************************************************************* |
| 619 | * |
| 620 | * FUNCTION: acpi_load_tables |
| 621 | * |
| 622 | * PARAMETERS: None |
| 623 | * |
| 624 | * RETURN: Status |
| 625 | * |
| 626 | * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT |
| 627 | * |
| 628 | ******************************************************************************/ |
| 629 | |
| 630 | acpi_status acpi_load_tables(void) |
| 631 | { |
| 632 | acpi_status status; |
| 633 | |
| 634 | ACPI_FUNCTION_TRACE(acpi_load_tables); |
| 635 | |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 636 | /* Load the namespace from the tables */ |
| 637 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 638 | status = acpi_tb_load_namespace(); |
| 639 | if (ACPI_FAILURE(status)) { |
| 640 | ACPI_EXCEPTION((AE_INFO, status, |
| 641 | "While loading namespace from ACPI tables")); |
| 642 | } |
| 643 | |
| 644 | return_ACPI_STATUS(status); |
| 645 | } |
| 646 | |
| 647 | ACPI_EXPORT_SYMBOL(acpi_load_tables) |
Len Brown | 67effe8 | 2007-07-26 00:50:06 -0400 | [diff] [blame] | 648 | |
| 649 | |
Lin Ming | 3e08e2d | 2008-04-10 19:06:38 +0400 | [diff] [blame] | 650 | /******************************************************************************* |
| 651 | * |
| 652 | * FUNCTION: acpi_install_table_handler |
| 653 | * |
| 654 | * PARAMETERS: Handler - Table event handler |
| 655 | * Context - Value passed to the handler on each event |
| 656 | * |
| 657 | * RETURN: Status |
| 658 | * |
| 659 | * DESCRIPTION: Install table event handler |
| 660 | * |
| 661 | ******************************************************************************/ |
| 662 | acpi_status |
| 663 | acpi_install_table_handler(acpi_tbl_handler handler, void *context) |
| 664 | { |
| 665 | acpi_status status; |
| 666 | |
| 667 | ACPI_FUNCTION_TRACE(acpi_install_table_handler); |
| 668 | |
| 669 | if (!handler) { |
| 670 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
| 671 | } |
| 672 | |
| 673 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 674 | if (ACPI_FAILURE(status)) { |
| 675 | return_ACPI_STATUS(status); |
| 676 | } |
| 677 | |
| 678 | /* Don't allow more than one handler */ |
| 679 | |
| 680 | if (acpi_gbl_table_handler) { |
| 681 | status = AE_ALREADY_EXISTS; |
| 682 | goto cleanup; |
| 683 | } |
| 684 | |
| 685 | /* Install the handler */ |
| 686 | |
| 687 | acpi_gbl_table_handler = handler; |
| 688 | acpi_gbl_table_handler_context = context; |
| 689 | |
| 690 | cleanup: |
| 691 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
| 692 | return_ACPI_STATUS(status); |
| 693 | } |
| 694 | |
| 695 | ACPI_EXPORT_SYMBOL(acpi_install_table_handler) |
| 696 | |
| 697 | /******************************************************************************* |
| 698 | * |
| 699 | * FUNCTION: acpi_remove_table_handler |
| 700 | * |
| 701 | * PARAMETERS: Handler - Table event handler that was installed |
| 702 | * previously. |
| 703 | * |
| 704 | * RETURN: Status |
| 705 | * |
| 706 | * DESCRIPTION: Remove table event handler |
| 707 | * |
| 708 | ******************************************************************************/ |
| 709 | acpi_status acpi_remove_table_handler(acpi_tbl_handler handler) |
| 710 | { |
| 711 | acpi_status status; |
| 712 | |
| 713 | ACPI_FUNCTION_TRACE(acpi_remove_table_handler); |
| 714 | |
| 715 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 716 | if (ACPI_FAILURE(status)) { |
| 717 | return_ACPI_STATUS(status); |
| 718 | } |
| 719 | |
| 720 | /* Make sure that the installed handler is the same */ |
| 721 | |
| 722 | if (!handler || handler != acpi_gbl_table_handler) { |
| 723 | status = AE_BAD_PARAMETER; |
| 724 | goto cleanup; |
| 725 | } |
| 726 | |
| 727 | /* Remove the handler */ |
| 728 | |
| 729 | acpi_gbl_table_handler = NULL; |
| 730 | |
| 731 | cleanup: |
| 732 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
| 733 | return_ACPI_STATUS(status); |
| 734 | } |
| 735 | |
| 736 | ACPI_EXPORT_SYMBOL(acpi_remove_table_handler) |
| 737 | |
| 738 | |
Len Brown | 67effe8 | 2007-07-26 00:50:06 -0400 | [diff] [blame] | 739 | static int __init acpi_no_auto_ssdt_setup(char *s) { |
| 740 | |
| 741 | printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n"); |
| 742 | |
| 743 | no_auto_ssdt = 1; |
| 744 | |
| 745 | return 1; |
| 746 | } |
| 747 | |
| 748 | __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup); |