blob: d4618648ea13b53ef6f78d9b9d94d16ed8fc3321 [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 Moorec8100dc2016-01-15 08:17:03 +08008 * Copyright (C) 2000 - 2016, 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>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
Len Browne2f7a772009-01-09 00:30:03 -050046#include "actables.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
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
Lv Zheng86dfc6f32014-04-04 12:38:57 +080051/* Local prototypes */
Bob Moorec418ce12014-04-04 12:39:34 +080052static u8
53acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index);
Lv Zheng86dfc6f32014-04-04 12:38:57 +080054
Bob Moorec418ce12014-04-04 12:39:34 +080055/*******************************************************************************
56 *
57 * FUNCTION: acpi_tb_compare_tables
58 *
59 * PARAMETERS: table_desc - Table 1 descriptor to be compared
60 * table_index - Index of table 2 to be compared
61 *
62 * RETURN: TRUE if both tables are identical.
63 *
64 * DESCRIPTION: This function compares a table with another table that has
65 * already been installed in the root table list.
66 *
67 ******************************************************************************/
Lv Zheng86dfc6f32014-04-04 12:38:57 +080068
69static u8
Bob Moorec418ce12014-04-04 12:39:34 +080070acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Alexey Starikovskiy428f2112007-02-02 19:48:22 +030072 acpi_status status = AE_OK;
Bob Moorec418ce12014-04-04 12:39:34 +080073 u8 is_identical;
74 struct acpi_table_header *table;
75 u32 table_length;
76 u8 table_flags;
Lv Zheng86dfc6f32014-04-04 12:38:57 +080077
78 status =
Bob Moorec418ce12014-04-04 12:39:34 +080079 acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index],
80 &table, &table_length, &table_flags);
Lv Zheng86dfc6f32014-04-04 12:38:57 +080081 if (ACPI_FAILURE(status)) {
Bob Moorec418ce12014-04-04 12:39:34 +080082 return (FALSE);
Lv Zheng86dfc6f32014-04-04 12:38:57 +080083 }
84
Bob Moorebc45b1d2008-06-10 14:12:50 +080085 /*
Bob Moorec418ce12014-04-04 12:39:34 +080086 * Check for a table match on the entire table length,
87 * not just the header.
Bob Moorebc45b1d2008-06-10 14:12:50 +080088 */
Bob Moorec418ce12014-04-04 12:39:34 +080089 is_identical = (u8)((table_desc->length != table_length ||
Bob Moore4fa46162015-07-01 14:45:11 +080090 memcmp(table_desc->pointer, table, table_length)) ?
91 FALSE : TRUE);
Bob Moorec8cefe32011-06-14 10:42:53 +080092
Bob Moorec418ce12014-04-04 12:39:34 +080093 /* Release the acquired table */
Lv Zheng86dfc6f32014-04-04 12:38:57 +080094
Bob Moorec418ce12014-04-04 12:39:34 +080095 acpi_tb_release_table(table, table_length, table_flags);
96 return (is_identical);
Lv Zheng86dfc6f32014-04-04 12:38:57 +080097}
Bob Mooree56f5612008-07-04 10:48:43 +080098
Lv Zheng86dfc6f32014-04-04 12:38:57 +080099/*******************************************************************************
100 *
Bob Mooreed6f1d42014-04-04 12:39:26 +0800101 * FUNCTION: acpi_tb_install_table_with_override
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800102 *
Lv Zheng8ec3f452015-08-25 10:29:01 +0800103 * PARAMETERS: new_table_desc - New table descriptor to install
Lv Zhengcaf4a152014-04-04 12:39:18 +0800104 * override - Whether override should be performed
Lv Zheng8ec3f452015-08-25 10:29:01 +0800105 * table_index - Where the table index is returned
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800106 *
107 * RETURN: None
108 *
109 * DESCRIPTION: Install an ACPI table into the global data structure. The
110 * table override mechanism is called to allow the host
111 * OS to replace any table before it is installed in the root
112 * table array.
113 *
114 ******************************************************************************/
Bob Mooref3d2e782007-02-02 19:48:18 +0300115
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800116void
Lv Zheng8ec3f452015-08-25 10:29:01 +0800117acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
118 u8 override, u32 *table_index)
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800119{
Lv Zheng8ec3f452015-08-25 10:29:01 +0800120 u32 i;
121 acpi_status status;
Bob Mooreed6f1d42014-04-04 12:39:26 +0800122
Lv Zheng8ec3f452015-08-25 10:29:01 +0800123 status = acpi_tb_get_next_table_descriptor(&i, NULL);
124 if (ACPI_FAILURE(status)) {
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800125 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 }
127
Bob Moored3ccaff2009-02-03 14:43:04 +0800128 /*
129 * ACPI Table Override:
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800130 *
131 * Before we install the table, let the host OS override it with a new
132 * one if desired. Any table within the RSDT/XSDT can be replaced,
133 * including the DSDT which is pointed to by the FADT.
Bob Moored3ccaff2009-02-03 14:43:04 +0800134 */
Lv Zhengcaf4a152014-04-04 12:39:18 +0800135 if (override) {
136 acpi_tb_override_table(new_table_desc);
137 }
Lv Zheng7f9fc992014-04-04 12:38:42 +0800138
Lv Zheng8ec3f452015-08-25 10:29:01 +0800139 acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[i],
Bob Mooreed6f1d42014-04-04 12:39:26 +0800140 new_table_desc->address,
141 new_table_desc->flags,
142 new_table_desc->pointer);
Lv Zheng7f9fc992014-04-04 12:38:42 +0800143
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800144 acpi_tb_print_table_header(new_table_desc->address,
145 new_table_desc->pointer);
146
Lv Zheng8ec3f452015-08-25 10:29:01 +0800147 /* This synchronizes acpi_gbl_dsdt_index */
148
149 *table_index = i;
150
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800151 /* Set the global integer width (based upon revision of the DSDT) */
152
Lv Zheng8ec3f452015-08-25 10:29:01 +0800153 if (i == acpi_gbl_dsdt_index) {
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800154 acpi_ut_set_integer_width(new_table_desc->pointer->revision);
155 }
156}
157
158/*******************************************************************************
159 *
Bob Mooreed6f1d42014-04-04 12:39:26 +0800160 * FUNCTION: acpi_tb_install_standard_table
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800161 *
Lv Zheng8a216d72014-04-04 12:39:04 +0800162 * PARAMETERS: address - Address of the table (might be a virtual
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800163 * address depending on the table_flags)
164 * flags - Flags for the table
165 * reload - Whether reload should be performed
Lv Zhengcaf4a152014-04-04 12:39:18 +0800166 * override - Whether override should be performed
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800167 * table_index - Where the table index is returned
168 *
169 * RETURN: Status
170 *
Lv Zheng752db102016-09-07 14:06:17 +0800171 * DESCRIPTION: This function is called to verify and install an ACPI table.
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800172 * When this function is called by "Load" or "LoadTable" opcodes,
173 * or by acpi_load_table() API, the "Reload" parameter is set.
174 * After sucessfully returning from this function, table is
175 * "INSTALLED" but not "VALIDATED".
176 *
177 ******************************************************************************/
178
179acpi_status
Bob Mooreed6f1d42014-04-04 12:39:26 +0800180acpi_tb_install_standard_table(acpi_physical_address address,
181 u8 flags,
182 u8 reload, u8 override, u32 *table_index)
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800183{
184 u32 i;
185 acpi_status status = AE_OK;
186 struct acpi_table_desc new_table_desc;
187
Bob Mooreed6f1d42014-04-04 12:39:26 +0800188 ACPI_FUNCTION_TRACE(tb_install_standard_table);
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800189
Bob Mooreed6f1d42014-04-04 12:39:26 +0800190 /* Acquire a temporary table descriptor for validation */
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800191
Bob Mooreed6f1d42014-04-04 12:39:26 +0800192 status = acpi_tb_acquire_temp_table(&new_table_desc, address, flags);
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800193 if (ACPI_FAILURE(status)) {
Lv Zhengcc2080b2015-04-13 11:48:46 +0800194 ACPI_ERROR((AE_INFO,
195 "Could not acquire table length at %8.8X%8.8X",
196 ACPI_FORMAT_UINT64(address)));
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800197 return_ACPI_STATUS(status);
198 }
199
Lv Zhenga94e88c2014-04-04 12:39:11 +0800200 /*
201 * Optionally do not load any SSDTs from the RSDT/XSDT. This can
202 * be useful for debugging ACPI problems on some machines.
203 */
Bob Mooreed6f1d42014-04-04 12:39:26 +0800204 if (!reload &&
205 acpi_gbl_disable_ssdt_table_install &&
Lv Zhenga94e88c2014-04-04 12:39:11 +0800206 ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) {
Bob Moore05fb04b2016-02-19 14:16:42 +0800207 ACPI_INFO(("Ignoring installation of %4.4s at %8.8X%8.8X",
Lv Zheng6d3fd3c2015-04-13 11:48:37 +0800208 new_table_desc.signature.ascii,
Lv Zhengcc2080b2015-04-13 11:48:46 +0800209 ACPI_FORMAT_UINT64(address)));
Lv Zhenga94e88c2014-04-04 12:39:11 +0800210 goto release_and_exit;
211 }
212
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800213 /* Validate and verify a table before installation */
214
Lv Zheng47d68c72014-05-31 08:14:44 +0800215 status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800216 if (ACPI_FAILURE(status)) {
217 goto release_and_exit;
218 }
219
220 if (reload) {
221 /*
222 * Validate the incoming table signature.
223 *
224 * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
225 * 2) We added support for OEMx tables, signature "OEM".
226 * 3) Valid tables were encountered with a null signature, so we just
227 * gave up on validating the signature, (05/2008).
228 * 4) We encountered non-AML tables such as the MADT, which caused
229 * interpreter errors and kernel faults. So now, we once again allow
230 * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
231 */
232 if ((new_table_desc.signature.ascii[0] != 0x00) &&
233 (!ACPI_COMPARE_NAME
234 (&new_table_desc.signature, ACPI_SIG_SSDT))
Bob Moore4fa46162015-07-01 14:45:11 +0800235 && (strncmp(new_table_desc.signature.ascii, "OEM", 3))) {
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800236 ACPI_BIOS_ERROR((AE_INFO,
237 "Table has invalid signature [%4.4s] (0x%8.8X), "
238 "must be SSDT or OEMx",
Bob Moore6a0df322016-05-05 13:00:36 +0800239 acpi_ut_valid_nameseg(new_table_desc.
240 signature.
241 ascii) ?
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800242 new_table_desc.signature.
243 ascii : "????",
244 new_table_desc.signature.integer));
245
246 status = AE_BAD_SIGNATURE;
247 goto release_and_exit;
248 }
249
250 /* Check if table is already registered */
251
252 for (i = 0; i < acpi_gbl_root_table_list.current_table_count;
253 ++i) {
254 /*
255 * Check for a table match on the entire table length,
256 * not just the header.
257 */
Bob Moorec418ce12014-04-04 12:39:34 +0800258 if (!acpi_tb_compare_tables(&new_table_desc, i)) {
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800259 continue;
260 }
261
262 /*
263 * Note: the current mechanism does not unregister a table if it is
264 * dynamically unloaded. The related namespace entries are deleted,
265 * but the table remains in the root table list.
266 *
267 * The assumption here is that the number of different tables that
268 * will be loaded is actually small, and there is minimal overhead
269 * in just keeping the table in case it is needed again.
270 *
271 * If this assumption changes in the future (perhaps on large
272 * machines with many table load/unload operations), tables will
273 * need to be unregistered when they are unloaded, and slots in the
274 * root table list should be reused when empty.
275 */
Bob Moore1fad8732015-12-29 13:54:36 +0800276 if (acpi_gbl_root_table_list.tables[i].flags &
277 ACPI_TABLE_IS_LOADED) {
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800278
279 /* Table is still loaded, this is an error */
280
281 status = AE_ALREADY_EXISTS;
282 goto release_and_exit;
283 } else {
284 /*
285 * Table was unloaded, allow it to be reloaded.
286 * As we are going to return AE_OK to the caller, we should
287 * take the responsibility of freeing the input descriptor.
288 * Refill the input descriptor to ensure
Bob Mooreed6f1d42014-04-04 12:39:26 +0800289 * acpi_tb_install_table_with_override() can be called again to
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800290 * indicate the re-installation.
291 */
292 acpi_tb_uninstall_table(&new_table_desc);
293 *table_index = i;
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800294 return_ACPI_STATUS(AE_OK);
295 }
296 }
Lv Zheng7f9fc992014-04-04 12:38:42 +0800297 }
Bob Moored3ccaff2009-02-03 14:43:04 +0800298
Bob Mooree56f5612008-07-04 10:48:43 +0800299 /* Add the table to the global root table list */
300
Lv Zheng8ec3f452015-08-25 10:29:01 +0800301 acpi_tb_install_table_with_override(&new_table_desc, override,
302 table_index);
Robert Moore0c9938c2005-07-29 15:15:00 -0700303
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800304release_and_exit:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Bob Mooreed6f1d42014-04-04 12:39:26 +0800306 /* Release the temporary table descriptor */
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800307
Bob Mooreed6f1d42014-04-04 12:39:26 +0800308 acpi_tb_release_temp_table(&new_table_desc);
Len Brown4be44fc2005-08-05 00:44:28 -0400309 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310}
311
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312/*******************************************************************************
313 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800314 * FUNCTION: acpi_tb_override_table
Bob Mooref7b004a2012-02-14 18:31:56 +0800315 *
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800316 * PARAMETERS: old_table_desc - Validated table descriptor to be
317 * overridden
Bob Mooref7b004a2012-02-14 18:31:56 +0800318 *
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800319 * RETURN: None
Bob Mooref7b004a2012-02-14 18:31:56 +0800320 *
321 * DESCRIPTION: Attempt table override by calling the OSL override functions.
322 * Note: If the table is overridden, then the entire new table
Lv Zheng7f9fc992014-04-04 12:38:42 +0800323 * is acquired and returned by this function.
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800324 * Before/after invocation, the table descriptor is in a state
325 * that is "VALIDATED".
Bob Mooref7b004a2012-02-14 18:31:56 +0800326 *
327 ******************************************************************************/
328
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800329void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
Bob Mooref7b004a2012-02-14 18:31:56 +0800330{
331 acpi_status status;
Bob Mooref7b004a2012-02-14 18:31:56 +0800332 char *override_type;
Lv Zheng7f9fc992014-04-04 12:38:42 +0800333 struct acpi_table_desc new_table_desc;
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800334 struct acpi_table_header *table;
335 acpi_physical_address address;
336 u32 length;
Bob Mooref7b004a2012-02-14 18:31:56 +0800337
338 /* (1) Attempt logical override (returns a logical address) */
339
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800340 status = acpi_os_table_override(old_table_desc->pointer, &table);
341 if (ACPI_SUCCESS(status) && table) {
Bob Mooreed6f1d42014-04-04 12:39:26 +0800342 acpi_tb_acquire_temp_table(&new_table_desc,
343 ACPI_PTR_TO_PHYSADDR(table),
344 ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL);
Bob Mooref7b004a2012-02-14 18:31:56 +0800345 override_type = "Logical";
346 goto finish_override;
347 }
348
349 /* (2) Attempt physical override (returns a physical address) */
350
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800351 status = acpi_os_physical_table_override(old_table_desc->pointer,
352 &address, &length);
353 if (ACPI_SUCCESS(status) && address && length) {
Bob Mooreed6f1d42014-04-04 12:39:26 +0800354 acpi_tb_acquire_temp_table(&new_table_desc, address,
355 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
Bob Mooref7b004a2012-02-14 18:31:56 +0800356 override_type = "Physical";
Bob Mooref7b004a2012-02-14 18:31:56 +0800357 goto finish_override;
358 }
359
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800360 return; /* There was no override */
Bob Mooref7b004a2012-02-14 18:31:56 +0800361
Lv Zheng10622bf2013-10-29 09:30:02 +0800362finish_override:
Bob Mooref7b004a2012-02-14 18:31:56 +0800363
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800364 /* Validate and verify a table before overriding */
365
Lv Zheng47d68c72014-05-31 08:14:44 +0800366 status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
Lv Zheng7f9fc992014-04-04 12:38:42 +0800367 if (ACPI_FAILURE(status)) {
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800368 return;
Lv Zheng7f9fc992014-04-04 12:38:42 +0800369 }
370
Bob Moore05fb04b2016-02-19 14:16:42 +0800371 ACPI_INFO(("%4.4s 0x%8.8X%8.8X"
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800372 " %s table override, new table: 0x%8.8X%8.8X",
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800373 old_table_desc->signature.ascii,
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800374 ACPI_FORMAT_UINT64(old_table_desc->address),
375 override_type, ACPI_FORMAT_UINT64(new_table_desc.address)));
Bob Mooref7b004a2012-02-14 18:31:56 +0800376
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800377 /* We can now uninstall the original table */
Bob Mooref7b004a2012-02-14 18:31:56 +0800378
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800379 acpi_tb_uninstall_table(old_table_desc);
Bob Mooref7b004a2012-02-14 18:31:56 +0800380
Lv Zheng86dfc6f32014-04-04 12:38:57 +0800381 /*
382 * Replace the original table descriptor and keep its state as
383 * "VALIDATED".
384 */
Bob Mooreed6f1d42014-04-04 12:39:26 +0800385 acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
386 new_table_desc.flags,
387 new_table_desc.pointer);
Lv Zheng47d68c72014-05-31 08:14:44 +0800388 acpi_tb_validate_temp_table(old_table_desc);
Bob Mooref7b004a2012-02-14 18:31:56 +0800389
Bob Mooreed6f1d42014-04-04 12:39:26 +0800390 /* Release the temporary table descriptor */
Bob Mooref7b004a2012-02-14 18:31:56 +0800391
Bob Mooreed6f1d42014-04-04 12:39:26 +0800392 acpi_tb_release_temp_table(&new_table_desc);
Bob Mooref7b004a2012-02-14 18:31:56 +0800393}
394
395/*******************************************************************************
396 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800397 * FUNCTION: acpi_tb_uninstall_table
Bob Mooref3d2e782007-02-02 19:48:18 +0300398 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800399 * PARAMETERS: table_desc - Table descriptor
Bob Mooref3d2e782007-02-02 19:48:18 +0300400 *
401 * RETURN: None
402 *
403 * DESCRIPTION: Delete one internal ACPI table
404 *
405 ******************************************************************************/
406
Lv Zheng7f9fc992014-04-04 12:38:42 +0800407void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
Bob Mooref3d2e782007-02-02 19:48:18 +0300408{
Lv Zheng55829822014-04-04 12:38:18 +0800409
Lv Zheng7f9fc992014-04-04 12:38:42 +0800410 ACPI_FUNCTION_TRACE(tb_uninstall_table);
Lv Zheng55829822014-04-04 12:38:18 +0800411
Lv Zheng7f9fc992014-04-04 12:38:42 +0800412 /* Table must be installed */
413
414 if (!table_desc->address) {
415 return_VOID;
Bob Mooref3d2e782007-02-02 19:48:18 +0300416 }
Lv Zheng55829822014-04-04 12:38:18 +0800417
Lv Zheng7f9fc992014-04-04 12:38:42 +0800418 acpi_tb_invalidate_table(table_desc);
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000419
Lv Zheng7f9fc992014-04-04 12:38:42 +0800420 if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
Bob Mooreed6f1d42014-04-04 12:39:26 +0800421 ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
Lv Zheng6d3fd3c2015-04-13 11:48:37 +0800422 ACPI_FREE(ACPI_PHYSADDR_TO_PTR(table_desc->address));
Bob Mooref3d2e782007-02-02 19:48:18 +0300423 }
424
Lv Zheng7f9fc992014-04-04 12:38:42 +0800425 table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
Lv Zheng7f9fc992014-04-04 12:38:42 +0800426 return_VOID;
Bob Mooref3d2e782007-02-02 19:48:18 +0300427}