Linux Audio

Check our new training course

Loading...
v6.13.7
  1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2/******************************************************************************
  3 *
  4 * Module Name: tbinstal - ACPI table installation and removal
  5 *
  6 * Copyright (C) 2000 - 2023, Intel Corp.
  7 *
  8 *****************************************************************************/
  9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 10#include <acpi/acpi.h>
 11#include "accommon.h"
 12#include "actables.h"
 13
 14#define _COMPONENT          ACPI_TABLES
 15ACPI_MODULE_NAME("tbinstal")
 16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 17/*******************************************************************************
 18 *
 19 * FUNCTION:    acpi_tb_install_table_with_override
 20 *
 21 * PARAMETERS:  new_table_desc          - New table descriptor to install
 22 *              override                - Whether override should be performed
 23 *              table_index             - Where the table index is returned
 24 *
 25 * RETURN:      None
 26 *
 27 * DESCRIPTION: Install an ACPI table into the global data structure. The
 28 *              table override mechanism is called to allow the host
 29 *              OS to replace any table before it is installed in the root
 30 *              table array.
 31 *
 32 ******************************************************************************/
 
 33void
 34acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
 35				    u8 override, u32 *table_index)
 36{
 37	u32 i;
 38	acpi_status status;
 39
 40	status = acpi_tb_get_next_table_descriptor(&i, NULL);
 41	if (ACPI_FAILURE(status)) {
 42		return;
 43	}
 44
 45	/*
 46	 * ACPI Table Override:
 47	 *
 48	 * Before we install the table, let the host OS override it with a new
 49	 * one if desired. Any table within the RSDT/XSDT can be replaced,
 50	 * including the DSDT which is pointed to by the FADT.
 51	 */
 52	if (override) {
 53		acpi_tb_override_table(new_table_desc);
 54	}
 55
 56	acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[i],
 57				      new_table_desc->address,
 58				      new_table_desc->flags,
 59				      new_table_desc->pointer);
 60
 61	acpi_tb_print_table_header(new_table_desc->address,
 62				   new_table_desc->pointer);
 63
 64	/* This synchronizes acpi_gbl_dsdt_index */
 65
 66	*table_index = i;
 67
 68	/* Set the global integer width (based upon revision of the DSDT) */
 69
 70	if (i == acpi_gbl_dsdt_index) {
 71		acpi_ut_set_integer_width(new_table_desc->pointer->revision);
 72	}
 73}
 74
 75/*******************************************************************************
 76 *
 77 * FUNCTION:    acpi_tb_install_standard_table
 78 *
 79 * PARAMETERS:  address             - Address of the table (might be a virtual
 80 *                                    address depending on the table_flags)
 81 *              flags               - Flags for the table
 82 *              table               - Pointer to the table (required for virtual
 83 *                                    origins, optional for physical)
 84 *              reload              - Whether reload should be performed
 85 *              override            - Whether override should be performed
 86 *              table_index         - Where the table index is returned
 87 *
 88 * RETURN:      Status
 89 *
 90 * DESCRIPTION: This function is called to verify and install an ACPI table.
 91 *              When this function is called by "Load" or "LoadTable" opcodes,
 92 *              or by acpi_load_table() API, the "Reload" parameter is set.
 93 *              After successfully returning from this function, table is
 94 *              "INSTALLED" but not "VALIDATED".
 95 *
 96 ******************************************************************************/
 97
 98acpi_status
 99acpi_tb_install_standard_table(acpi_physical_address address,
100			       u8 flags,
101			       struct acpi_table_header *table,
102			       u8 reload, u8 override, u32 *table_index)
103{
104	u32 i;
105	acpi_status status = AE_OK;
106	struct acpi_table_desc new_table_desc;
107
108	ACPI_FUNCTION_TRACE(tb_install_standard_table);
109
110	/* Acquire a temporary table descriptor for validation */
111
112	status =
113	    acpi_tb_acquire_temp_table(&new_table_desc, address, flags, table);
114	if (ACPI_FAILURE(status)) {
115		ACPI_ERROR((AE_INFO,
116			    "Could not acquire table length at %8.8X%8.8X",
117			    ACPI_FORMAT_UINT64(address)));
118		return_ACPI_STATUS(status);
119	}
120
121	/*
122	 * Optionally do not load any SSDTs from the RSDT/XSDT. This can
123	 * be useful for debugging ACPI problems on some machines.
124	 */
125	if (!reload &&
126	    acpi_gbl_disable_ssdt_table_install &&
127	    ACPI_COMPARE_NAMESEG(&new_table_desc.signature, ACPI_SIG_SSDT)) {
128		ACPI_INFO(("Ignoring installation of %4.4s at %8.8X%8.8X",
129			   new_table_desc.signature.ascii,
130			   ACPI_FORMAT_UINT64(address)));
131		goto release_and_exit;
132	}
133
 
 
 
 
 
 
 
134	/* Acquire the table lock */
135
136	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
137
138	/* Validate and verify a table before installation */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140	status = acpi_tb_verify_temp_table(&new_table_desc, NULL, &i);
141	if (ACPI_FAILURE(status)) {
142		if (status == AE_CTRL_TERMINATE) {
143			/*
144			 * Table was unloaded, allow it to be reloaded.
145			 * As we are going to return AE_OK to the caller, we should
146			 * take the responsibility of freeing the input descriptor.
147			 * Refill the input descriptor to ensure
148			 * acpi_tb_install_table_with_override() can be called again to
149			 * indicate the re-installation.
 
 
 
 
 
 
150			 */
151			acpi_tb_uninstall_table(&new_table_desc);
152			(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
153			*table_index = i;
154			return_ACPI_STATUS(AE_OK);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155		}
156		goto unlock_and_exit;
157	}
158
159	/* Add the table to the global root table list */
160
161	acpi_tb_install_table_with_override(&new_table_desc, override,
162					    table_index);
163
164	/* Invoke table handler */
165
166	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
167	acpi_tb_notify_table(ACPI_TABLE_EVENT_INSTALL, new_table_desc.pointer);
 
 
 
 
168	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
169
170unlock_and_exit:
171
172	/* Release the table lock */
173
174	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
175
176release_and_exit:
177
178	/* Release the temporary table descriptor */
179
180	acpi_tb_release_temp_table(&new_table_desc);
181	return_ACPI_STATUS(status);
182}
183
184/*******************************************************************************
185 *
186 * FUNCTION:    acpi_tb_override_table
187 *
188 * PARAMETERS:  old_table_desc      - Validated table descriptor to be
189 *                                    overridden
190 *
191 * RETURN:      None
192 *
193 * DESCRIPTION: Attempt table override by calling the OSL override functions.
194 *              Note: If the table is overridden, then the entire new table
195 *              is acquired and returned by this function.
196 *              Before/after invocation, the table descriptor is in a state
197 *              that is "VALIDATED".
198 *
199 ******************************************************************************/
200
201void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
202{
203	acpi_status status;
 
204	struct acpi_table_desc new_table_desc;
205	struct acpi_table_header *table;
206	acpi_physical_address address;
207	u32 length;
208	ACPI_ERROR_ONLY(char *override_type);
209
210	/* (1) Attempt logical override (returns a logical address) */
211
212	status = acpi_os_table_override(old_table_desc->pointer, &table);
213	if (ACPI_SUCCESS(status) && table) {
214		acpi_tb_acquire_temp_table(&new_table_desc,
215					   ACPI_PTR_TO_PHYSADDR(table),
216					   ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL,
217					   table);
218		ACPI_ERROR_ONLY(override_type = "Logical");
219		goto finish_override;
220	}
221
222	/* (2) Attempt physical override (returns a physical address) */
223
224	status = acpi_os_physical_table_override(old_table_desc->pointer,
225						 &address, &length);
226	if (ACPI_SUCCESS(status) && address && length) {
227		acpi_tb_acquire_temp_table(&new_table_desc, address,
228					   ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
229					   NULL);
230		ACPI_ERROR_ONLY(override_type = "Physical");
231		goto finish_override;
232	}
233
234	return;			/* There was no override */
235
236finish_override:
237
238	/*
239	 * Validate and verify a table before overriding, no nested table
240	 * duplication check as it's too complicated and unnecessary.
241	 */
242	status = acpi_tb_verify_temp_table(&new_table_desc, NULL, NULL);
243	if (ACPI_FAILURE(status)) {
244		return;
245	}
246
247	ACPI_INFO(("%4.4s 0x%8.8X%8.8X"
248		   " %s table override, new table: 0x%8.8X%8.8X",
249		   old_table_desc->signature.ascii,
250		   ACPI_FORMAT_UINT64(old_table_desc->address),
251		   override_type, ACPI_FORMAT_UINT64(new_table_desc.address)));
252
253	/* We can now uninstall the original table */
254
255	acpi_tb_uninstall_table(old_table_desc);
256
257	/*
258	 * Replace the original table descriptor and keep its state as
259	 * "VALIDATED".
260	 */
261	acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
262				      new_table_desc.flags,
263				      new_table_desc.pointer);
264	acpi_tb_validate_temp_table(old_table_desc);
265
266	/* Release the temporary table descriptor */
267
268	acpi_tb_release_temp_table(&new_table_desc);
269}
270
271/*******************************************************************************
272 *
273 * FUNCTION:    acpi_tb_uninstall_table
274 *
275 * PARAMETERS:  table_desc          - Table descriptor
276 *
277 * RETURN:      None
278 *
279 * DESCRIPTION: Delete one internal ACPI table
280 *
281 ******************************************************************************/
282
283void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
284{
285
286	ACPI_FUNCTION_TRACE(tb_uninstall_table);
287
288	/* Table must be installed */
289
290	if (!table_desc->address) {
291		return_VOID;
292	}
293
294	acpi_tb_invalidate_table(table_desc);
295
296	if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
297	    ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
298		ACPI_FREE(table_desc->pointer);
299		table_desc->pointer = NULL;
300	}
301
302	table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
303	return_VOID;
304}
v4.10.11
 
  1/******************************************************************************
  2 *
  3 * Module Name: tbinstal - ACPI table installation and removal
  4 *
 
 
  5 *****************************************************************************/
  6
  7/*
  8 * Copyright (C) 2000 - 2016, Intel Corp.
  9 * 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
 44#include <acpi/acpi.h>
 45#include "accommon.h"
 46#include "actables.h"
 47
 48#define _COMPONENT          ACPI_TABLES
 49ACPI_MODULE_NAME("tbinstal")
 50
 51/* Local prototypes */
 52static u8
 53acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index);
 54
 55/*******************************************************************************
 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 ******************************************************************************/
 68
 69static u8
 70acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index)
 71{
 72	acpi_status status = AE_OK;
 73	u8 is_identical;
 74	struct acpi_table_header *table;
 75	u32 table_length;
 76	u8 table_flags;
 77
 78	status =
 79	    acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index],
 80				  &table, &table_length, &table_flags);
 81	if (ACPI_FAILURE(status)) {
 82		return (FALSE);
 83	}
 84
 85	/*
 86	 * Check for a table match on the entire table length,
 87	 * not just the header.
 88	 */
 89	is_identical = (u8)((table_desc->length != table_length ||
 90			     memcmp(table_desc->pointer, table, table_length)) ?
 91			    FALSE : TRUE);
 92
 93	/* Release the acquired table */
 94
 95	acpi_tb_release_table(table, table_length, table_flags);
 96	return (is_identical);
 97}
 98
 99/*******************************************************************************
100 *
101 * FUNCTION:    acpi_tb_install_table_with_override
102 *
103 * PARAMETERS:  new_table_desc          - New table descriptor to install
104 *              override                - Whether override should be performed
105 *              table_index             - Where the table index is returned
106 *
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 ******************************************************************************/
115
116void
117acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
118				    u8 override, u32 *table_index)
119{
120	u32 i;
121	acpi_status status;
122
123	status = acpi_tb_get_next_table_descriptor(&i, NULL);
124	if (ACPI_FAILURE(status)) {
125		return;
126	}
127
128	/*
129	 * ACPI Table Override:
130	 *
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.
134	 */
135	if (override) {
136		acpi_tb_override_table(new_table_desc);
137	}
138
139	acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[i],
140				      new_table_desc->address,
141				      new_table_desc->flags,
142				      new_table_desc->pointer);
143
144	acpi_tb_print_table_header(new_table_desc->address,
145				   new_table_desc->pointer);
146
147	/* This synchronizes acpi_gbl_dsdt_index */
148
149	*table_index = i;
150
151	/* Set the global integer width (based upon revision of the DSDT) */
152
153	if (i == acpi_gbl_dsdt_index) {
154		acpi_ut_set_integer_width(new_table_desc->pointer->revision);
155	}
156}
157
158/*******************************************************************************
159 *
160 * FUNCTION:    acpi_tb_install_standard_table
161 *
162 * PARAMETERS:  address             - Address of the table (might be a virtual
163 *                                    address depending on the table_flags)
164 *              flags               - Flags for the table
 
 
165 *              reload              - Whether reload should be performed
166 *              override            - Whether override should be performed
167 *              table_index         - Where the table index is returned
168 *
169 * RETURN:      Status
170 *
171 * DESCRIPTION: This function is called to verify and install an ACPI table.
172 *              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
180acpi_tb_install_standard_table(acpi_physical_address address,
181			       u8 flags,
 
182			       u8 reload, u8 override, u32 *table_index)
183{
184	u32 i;
185	acpi_status status = AE_OK;
186	struct acpi_table_desc new_table_desc;
187
188	ACPI_FUNCTION_TRACE(tb_install_standard_table);
189
190	/* Acquire a temporary table descriptor for validation */
191
192	status = acpi_tb_acquire_temp_table(&new_table_desc, address, flags);
 
193	if (ACPI_FAILURE(status)) {
194		ACPI_ERROR((AE_INFO,
195			    "Could not acquire table length at %8.8X%8.8X",
196			    ACPI_FORMAT_UINT64(address)));
197		return_ACPI_STATUS(status);
198	}
199
200	/*
201	 * Optionally do not load any SSDTs from the RSDT/XSDT. This can
202	 * be useful for debugging ACPI problems on some machines.
203	 */
204	if (!reload &&
205	    acpi_gbl_disable_ssdt_table_install &&
206	    ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) {
207		ACPI_INFO(("Ignoring installation of %4.4s at %8.8X%8.8X",
208			   new_table_desc.signature.ascii,
209			   ACPI_FORMAT_UINT64(address)));
210		goto release_and_exit;
211	}
212
213	/* Validate and verify a table before installation */
214
215	status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
216	if (ACPI_FAILURE(status)) {
217		goto release_and_exit;
218	}
219
220	/* Acquire the table lock */
221
222	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
223
224	if (reload) {
225		/*
226		 * Validate the incoming table signature.
227		 *
228		 * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
229		 * 2) We added support for OEMx tables, signature "OEM".
230		 * 3) Valid tables were encountered with a null signature, so we just
231		 *    gave up on validating the signature, (05/2008).
232		 * 4) We encountered non-AML tables such as the MADT, which caused
233		 *    interpreter errors and kernel faults. So now, we once again allow
234		 *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
235		 */
236		if ((new_table_desc.signature.ascii[0] != 0x00) &&
237		    (!ACPI_COMPARE_NAME
238		     (&new_table_desc.signature, ACPI_SIG_SSDT))
239		    && (strncmp(new_table_desc.signature.ascii, "OEM", 3))) {
240			ACPI_BIOS_ERROR((AE_INFO,
241					 "Table has invalid signature [%4.4s] (0x%8.8X), "
242					 "must be SSDT or OEMx",
243					 acpi_ut_valid_nameseg(new_table_desc.
244							       signature.
245							       ascii) ?
246					 new_table_desc.signature.
247					 ascii : "????",
248					 new_table_desc.signature.integer));
249
250			status = AE_BAD_SIGNATURE;
251			goto unlock_and_exit;
252		}
253
254		/* Check if table is already registered */
255
256		for (i = 0; i < acpi_gbl_root_table_list.current_table_count;
257		     ++i) {
258			/*
259			 * Check for a table match on the entire table length,
260			 * not just the header.
261			 */
262			if (!acpi_tb_compare_tables(&new_table_desc, i)) {
263				continue;
264			}
265
 
 
 
266			/*
267			 * Note: the current mechanism does not unregister a table if it is
268			 * dynamically unloaded. The related namespace entries are deleted,
269			 * but the table remains in the root table list.
270			 *
271			 * The assumption here is that the number of different tables that
272			 * will be loaded is actually small, and there is minimal overhead
273			 * in just keeping the table in case it is needed again.
274			 *
275			 * If this assumption changes in the future (perhaps on large
276			 * machines with many table load/unload operations), tables will
277			 * need to be unregistered when they are unloaded, and slots in the
278			 * root table list should be reused when empty.
279			 */
280			if (acpi_gbl_root_table_list.tables[i].flags &
281			    ACPI_TABLE_IS_LOADED) {
282
283				/* Table is still loaded, this is an error */
284
285				status = AE_ALREADY_EXISTS;
286				goto unlock_and_exit;
287			} else {
288				/*
289				 * Table was unloaded, allow it to be reloaded.
290				 * As we are going to return AE_OK to the caller, we should
291				 * take the responsibility of freeing the input descriptor.
292				 * Refill the input descriptor to ensure
293				 * acpi_tb_install_table_with_override() can be called again to
294				 * indicate the re-installation.
295				 */
296				acpi_tb_uninstall_table(&new_table_desc);
297				(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
298				*table_index = i;
299				return_ACPI_STATUS(AE_OK);
300			}
301		}
 
302	}
303
304	/* Add the table to the global root table list */
305
306	acpi_tb_install_table_with_override(&new_table_desc, override,
307					    table_index);
308
309	/* Invoke table handler if present */
310
311	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
312	if (acpi_gbl_table_handler) {
313		(void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_INSTALL,
314					     new_table_desc.pointer,
315					     acpi_gbl_table_handler_context);
316	}
317	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
318
319unlock_and_exit:
320
321	/* Release the table lock */
322
323	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
324
325release_and_exit:
326
327	/* Release the temporary table descriptor */
328
329	acpi_tb_release_temp_table(&new_table_desc);
330	return_ACPI_STATUS(status);
331}
332
333/*******************************************************************************
334 *
335 * FUNCTION:    acpi_tb_override_table
336 *
337 * PARAMETERS:  old_table_desc      - Validated table descriptor to be
338 *                                    overridden
339 *
340 * RETURN:      None
341 *
342 * DESCRIPTION: Attempt table override by calling the OSL override functions.
343 *              Note: If the table is overridden, then the entire new table
344 *              is acquired and returned by this function.
345 *              Before/after invocation, the table descriptor is in a state
346 *              that is "VALIDATED".
347 *
348 ******************************************************************************/
349
350void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
351{
352	acpi_status status;
353	char *override_type;
354	struct acpi_table_desc new_table_desc;
355	struct acpi_table_header *table;
356	acpi_physical_address address;
357	u32 length;
 
358
359	/* (1) Attempt logical override (returns a logical address) */
360
361	status = acpi_os_table_override(old_table_desc->pointer, &table);
362	if (ACPI_SUCCESS(status) && table) {
363		acpi_tb_acquire_temp_table(&new_table_desc,
364					   ACPI_PTR_TO_PHYSADDR(table),
365					   ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL);
366		override_type = "Logical";
 
367		goto finish_override;
368	}
369
370	/* (2) Attempt physical override (returns a physical address) */
371
372	status = acpi_os_physical_table_override(old_table_desc->pointer,
373						 &address, &length);
374	if (ACPI_SUCCESS(status) && address && length) {
375		acpi_tb_acquire_temp_table(&new_table_desc, address,
376					   ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
377		override_type = "Physical";
 
378		goto finish_override;
379	}
380
381	return;			/* There was no override */
382
383finish_override:
384
385	/* Validate and verify a table before overriding */
386
387	status = acpi_tb_verify_temp_table(&new_table_desc, NULL);
 
 
388	if (ACPI_FAILURE(status)) {
389		return;
390	}
391
392	ACPI_INFO(("%4.4s 0x%8.8X%8.8X"
393		   " %s table override, new table: 0x%8.8X%8.8X",
394		   old_table_desc->signature.ascii,
395		   ACPI_FORMAT_UINT64(old_table_desc->address),
396		   override_type, ACPI_FORMAT_UINT64(new_table_desc.address)));
397
398	/* We can now uninstall the original table */
399
400	acpi_tb_uninstall_table(old_table_desc);
401
402	/*
403	 * Replace the original table descriptor and keep its state as
404	 * "VALIDATED".
405	 */
406	acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
407				      new_table_desc.flags,
408				      new_table_desc.pointer);
409	acpi_tb_validate_temp_table(old_table_desc);
410
411	/* Release the temporary table descriptor */
412
413	acpi_tb_release_temp_table(&new_table_desc);
414}
415
416/*******************************************************************************
417 *
418 * FUNCTION:    acpi_tb_uninstall_table
419 *
420 * PARAMETERS:  table_desc          - Table descriptor
421 *
422 * RETURN:      None
423 *
424 * DESCRIPTION: Delete one internal ACPI table
425 *
426 ******************************************************************************/
427
428void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
429{
430
431	ACPI_FUNCTION_TRACE(tb_uninstall_table);
432
433	/* Table must be installed */
434
435	if (!table_desc->address) {
436		return_VOID;
437	}
438
439	acpi_tb_invalidate_table(table_desc);
440
441	if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
442	    ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
443		ACPI_FREE(ACPI_PHYSADDR_TO_PTR(table_desc->address));
 
444	}
445
446	table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
447	return_VOID;
448}