2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* Module Name: tbxface - ACPI table-oriented external interfaces
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2017-02-08 11:00:08 +08:00
|
|
|
* Copyright (C) 2000 - 2017, Intel Corp.
|
2005-04-17 06:20:36 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
2013-10-29 09:29:51 +08:00
|
|
|
#define EXPORT_ACPI_INTERFACES
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 13:30:03 +08:00
|
|
|
#include "accommon.h"
|
|
|
|
#include "actables.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_TABLES
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("tbxface")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:20 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_allocate_root_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: initial_table_count - Size of initial_table_array, in number of
|
|
|
|
* struct acpi_table_desc structures
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2012-07-12 09:40:10 +08:00
|
|
|
* DESCRIPTION: Allocate a root table array. Used by iASL compiler and
|
2007-02-03 00:48:20 +08:00
|
|
|
* acpi_initialize_tables.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status acpi_allocate_root_table(u32 initial_table_count)
|
|
|
|
{
|
|
|
|
|
2010-04-27 11:16:14 +08:00
|
|
|
acpi_gbl_root_table_list.max_table_count = initial_table_count;
|
2007-02-03 00:48:20 +08:00
|
|
|
acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
|
|
|
|
|
|
|
|
return (acpi_tb_resize_root_table_list());
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2007-02-03 00:48:18 +08:00
|
|
|
* FUNCTION: acpi_initialize_tables
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2007-02-03 00:48:18 +08:00
|
|
|
* PARAMETERS: initial_table_array - Pointer to an array of pre-allocated
|
|
|
|
* struct acpi_table_desc structures. If NULL, the
|
|
|
|
* array is dynamically allocated.
|
|
|
|
* initial_table_count - Size of initial_table_array, in number of
|
|
|
|
* struct acpi_table_desc structures
|
2013-04-12 08:24:53 +08:00
|
|
|
* allow_resize - Flag to tell Table Manager if resize of
|
2007-02-03 00:48:18 +08:00
|
|
|
* pre-allocated array is allowed. Ignored
|
|
|
|
* if initial_table_array is NULL.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2007-02-03 00:48:18 +08:00
|
|
|
* DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
|
|
|
|
*
|
|
|
|
* NOTE: Allows static allocation of the initial table array in order
|
|
|
|
* to avoid the use of dynamic memory in confined environments
|
|
|
|
* such as the kernel boot sequence where it may not be available.
|
|
|
|
*
|
|
|
|
* If the host OS memory managers are initialized, use NULL for
|
|
|
|
* initial_table_array, and the table will be dynamically allocated.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
2007-02-03 00:48:18 +08:00
|
|
|
|
2016-08-04 16:43:19 +08:00
|
|
|
acpi_status ACPI_INIT_FUNCTION
|
2016-05-05 12:57:53 +08:00
|
|
|
acpi_initialize_tables(struct acpi_table_desc *initial_table_array,
|
2007-02-03 00:48:18 +08:00
|
|
|
u32 initial_table_count, u8 allow_resize)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-03 00:48:19 +08:00
|
|
|
acpi_physical_address rsdp_address;
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
ACPI_FUNCTION_TRACE(acpi_initialize_tables);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
/*
|
2013-04-12 08:24:53 +08:00
|
|
|
* Setup the Root Table Array and allocate the table array
|
|
|
|
* if requested
|
2007-02-03 00:48:18 +08:00
|
|
|
*/
|
|
|
|
if (!initial_table_array) {
|
2007-02-03 00:48:20 +08:00
|
|
|
status = acpi_allocate_root_table(initial_table_count);
|
2007-02-03 00:48:18 +08:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Root Table Array has been statically allocated by the host */
|
|
|
|
|
2015-07-01 14:45:11 +08:00
|
|
|
memset(initial_table_array, 0,
|
2016-05-05 12:57:53 +08:00
|
|
|
(acpi_size)initial_table_count *
|
2015-07-01 14:45:11 +08:00
|
|
|
sizeof(struct acpi_table_desc));
|
2007-02-03 00:48:19 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
acpi_gbl_root_table_list.tables = initial_table_array;
|
2010-04-27 11:16:14 +08:00
|
|
|
acpi_gbl_root_table_list.max_table_count = initial_table_count;
|
2007-02-03 00:48:19 +08:00
|
|
|
acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
|
2007-02-03 00:48:18 +08:00
|
|
|
if (allow_resize) {
|
2007-02-03 00:48:19 +08:00
|
|
|
acpi_gbl_root_table_list.flags |=
|
|
|
|
ACPI_ROOT_ALLOW_RESIZE;
|
2007-02-03 00:48:18 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:19 +08:00
|
|
|
/* Get the address of the RSDP */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:19 +08:00
|
|
|
rsdp_address = acpi_os_get_root_pointer();
|
|
|
|
if (!rsdp_address) {
|
2007-02-03 00:48:18 +08:00
|
|
|
return_ACPI_STATUS(AE_NOT_FOUND);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
/*
|
|
|
|
* Get the root table (RSDT or XSDT) and extract all entries to the local
|
|
|
|
* Root Table Array. This array contains the information of the RSDT/XSDT
|
|
|
|
* in a common, more useable format.
|
|
|
|
*/
|
2009-02-03 14:41:03 +08:00
|
|
|
status = acpi_tb_parse_root_table(rsdp_address);
|
2007-02-03 00:48:18 +08:00
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-10-29 09:30:10 +08:00
|
|
|
ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_tables)
|
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_reallocate_root_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
|
|
|
|
* root list from the previously provided scratch area. Should
|
|
|
|
* be called once dynamic memory allocation is available in the
|
2012-09-14 00:29:06 +08:00
|
|
|
* kernel.
|
2007-02-03 00:48:18 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
2016-08-04 16:43:19 +08:00
|
|
|
acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
|
2007-02-03 00:48:18 +08:00
|
|
|
{
|
2012-09-14 00:29:06 +08:00
|
|
|
acpi_status status;
|
2016-11-30 15:21:34 +08:00
|
|
|
u32 i;
|
2007-02-03 00:48:18 +08:00
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only reallocate the root table if the host provided a static buffer
|
|
|
|
* for the table array in the call to acpi_initialize_tables.
|
|
|
|
*/
|
2007-02-03 00:48:19 +08:00
|
|
|
if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
|
2007-02-03 00:48:18 +08:00
|
|
|
return_ACPI_STATUS(AE_SUPPORT);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-11-30 15:21:34 +08:00
|
|
|
/*
|
|
|
|
* Ensure OS early boot logic, which is required by some hosts. If the
|
|
|
|
* table state is reported to be wrong, developers should fix the
|
|
|
|
* issue by invoking acpi_put_table() for the reported table during the
|
|
|
|
* early stage.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
|
|
|
|
if (acpi_gbl_root_table_list.tables[i].pointer) {
|
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Table [%4.4s] is not invalidated during early boot stage",
|
|
|
|
acpi_gbl_root_table_list.tables[i].
|
|
|
|
signature.ascii));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-14 00:29:06 +08:00
|
|
|
acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-09-14 00:29:06 +08:00
|
|
|
status = acpi_tb_resize_root_table_list();
|
|
|
|
return_ACPI_STATUS(status);
|
2007-02-03 00:48:18 +08:00
|
|
|
}
|
2007-05-10 11:34:35 +08:00
|
|
|
|
2013-10-29 09:30:10 +08:00
|
|
|
ACPI_EXPORT_SYMBOL_INIT(acpi_reallocate_root_table)
|
|
|
|
|
2009-02-18 15:03:30 +08:00
|
|
|
/*******************************************************************************
|
2007-02-03 00:48:18 +08:00
|
|
|
*
|
|
|
|
* FUNCTION: acpi_get_table_header
|
|
|
|
*
|
2012-07-12 09:40:10 +08:00
|
|
|
* PARAMETERS: signature - ACPI signature of needed table
|
|
|
|
* instance - Which instance (for SSDTs)
|
2007-02-03 00:48:22 +08:00
|
|
|
* out_table_header - The pointer to the table header to fill
|
2007-02-03 00:48:18 +08:00
|
|
|
*
|
|
|
|
* RETURN: Status and pointer to mapped table header
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Finds an ACPI table header.
|
|
|
|
*
|
|
|
|
* NOTE: Caller is responsible in unmapping the header with
|
|
|
|
* acpi_os_unmap_memory
|
|
|
|
*
|
2009-02-18 15:03:30 +08:00
|
|
|
******************************************************************************/
|
2007-02-03 00:48:18 +08:00
|
|
|
acpi_status
|
|
|
|
acpi_get_table_header(char *signature,
|
2008-06-10 13:42:13 +08:00
|
|
|
u32 instance, struct acpi_table_header *out_table_header)
|
2007-02-03 00:48:18 +08:00
|
|
|
{
|
2014-04-04 12:38:18 +08:00
|
|
|
u32 i;
|
|
|
|
u32 j;
|
2007-02-03 00:48:22 +08:00
|
|
|
struct acpi_table_header *header;
|
2005-07-30 06:15:00 +08:00
|
|
|
|
2007-02-03 00:48:19 +08:00
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!signature || !out_table_header) {
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2009-02-18 15:03:30 +08:00
|
|
|
/* Walk the root table list */
|
|
|
|
|
2010-04-27 11:16:14 +08:00
|
|
|
for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
|
|
|
|
i++) {
|
2007-02-03 00:48:18 +08:00
|
|
|
if (!ACPI_COMPARE_NAME
|
|
|
|
(&(acpi_gbl_root_table_list.tables[i].signature),
|
|
|
|
signature)) {
|
|
|
|
continue;
|
2005-07-30 06:15:00 +08:00
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
if (++j < instance) {
|
|
|
|
continue;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:22 +08:00
|
|
|
if (!acpi_gbl_root_table_list.tables[i].pointer) {
|
2009-02-18 15:03:30 +08:00
|
|
|
if ((acpi_gbl_root_table_list.tables[i].flags &
|
|
|
|
ACPI_TABLE_ORIGIN_MASK) ==
|
2014-04-04 12:39:26 +08:00
|
|
|
ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) {
|
2007-02-03 00:48:22 +08:00
|
|
|
header =
|
|
|
|
acpi_os_map_memory(acpi_gbl_root_table_list.
|
|
|
|
tables[i].address,
|
|
|
|
sizeof(struct
|
|
|
|
acpi_table_header));
|
|
|
|
if (!header) {
|
2012-10-31 10:26:01 +08:00
|
|
|
return (AE_NO_MEMORY);
|
2007-02-03 00:48:22 +08:00
|
|
|
}
|
2015-06-19 11:38:16 +08:00
|
|
|
|
2015-07-01 14:45:11 +08:00
|
|
|
memcpy(out_table_header, header,
|
|
|
|
sizeof(struct acpi_table_header));
|
2007-02-03 00:48:22 +08:00
|
|
|
acpi_os_unmap_memory(header,
|
|
|
|
sizeof(struct
|
|
|
|
acpi_table_header));
|
|
|
|
} else {
|
2012-10-31 10:26:01 +08:00
|
|
|
return (AE_NOT_FOUND);
|
2007-02-03 00:48:22 +08:00
|
|
|
}
|
|
|
|
} else {
|
2015-07-01 14:45:11 +08:00
|
|
|
memcpy(out_table_header,
|
|
|
|
acpi_gbl_root_table_list.tables[i].pointer,
|
|
|
|
sizeof(struct acpi_table_header));
|
2007-02-03 00:48:18 +08:00
|
|
|
}
|
|
|
|
return (AE_OK);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
return (AE_NOT_FOUND);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_get_table_header)
|
2006-10-03 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
* FUNCTION: acpi_get_table
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2012-07-12 09:40:10 +08:00
|
|
|
* PARAMETERS: signature - ACPI signature of needed table
|
|
|
|
* instance - Which instance (for SSDTs)
|
2007-02-03 00:48:18 +08:00
|
|
|
* out_table - Where the pointer to the table is returned
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* RETURN: Status and pointer to the requested table
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* DESCRIPTION: Finds and verifies an ACPI table. Table must be in the
|
|
|
|
* RSDT/XSDT.
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
* Note that an early stage acpi_get_table() call must be paired
|
|
|
|
* with an early stage acpi_put_table() call. otherwise the table
|
|
|
|
* pointer mapped by the early stage mapping implementation may be
|
|
|
|
* erroneously unmapped by the late stage unmapping implementation
|
|
|
|
* in an acpi_put_table() invoked during the late stage.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2009-02-18 15:03:30 +08:00
|
|
|
******************************************************************************/
|
2007-02-03 00:48:18 +08:00
|
|
|
acpi_status
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
acpi_get_table(char *signature,
|
|
|
|
u32 instance, struct acpi_table_header ** out_table)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2014-04-04 12:38:18 +08:00
|
|
|
u32 i;
|
|
|
|
u32 j;
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
acpi_status status = AE_NOT_FOUND;
|
|
|
|
struct acpi_table_desc *table_desc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:19 +08:00
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!signature || !out_table) {
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
/*
|
|
|
|
* Note that the following line is required by some OSPMs, they only
|
|
|
|
* check if the returned table is NULL instead of the returned status
|
|
|
|
* to determined if this function is succeeded.
|
|
|
|
*/
|
|
|
|
*out_table = NULL;
|
|
|
|
|
|
|
|
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
|
|
|
|
|
2009-02-18 15:03:30 +08:00
|
|
|
/* Walk the root table list */
|
|
|
|
|
2010-04-27 11:16:14 +08:00
|
|
|
for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
|
|
|
|
i++) {
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
table_desc = &acpi_gbl_root_table_list.tables[i];
|
|
|
|
|
|
|
|
if (!ACPI_COMPARE_NAME(&table_desc->signature, signature)) {
|
2007-02-03 00:48:18 +08:00
|
|
|
continue;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
if (++j < instance) {
|
|
|
|
continue;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
status = acpi_tb_get_table(table_desc, out_table);
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
|
|
|
|
return (status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2013-10-29 09:30:10 +08:00
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_get_table)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_put_table
|
|
|
|
*
|
|
|
|
* PARAMETERS: table - The pointer to the table
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Release a table returned by acpi_get_table() and its clones.
|
|
|
|
* Note that it is not safe if this function was invoked after an
|
|
|
|
* uninstallation happened to the original table descriptor.
|
|
|
|
* Currently there is no OSPMs' requirement to handle such
|
|
|
|
* situations.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
void acpi_put_table(struct acpi_table_header *table)
|
2009-02-08 07:39:41 +08:00
|
|
|
{
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
u32 i;
|
|
|
|
struct acpi_table_desc *table_desc;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE(acpi_put_table);
|
|
|
|
|
|
|
|
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
|
|
|
|
|
|
|
|
/* Walk the root table list */
|
|
|
|
|
|
|
|
for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
|
|
|
|
table_desc = &acpi_gbl_root_table_list.tables[i];
|
2009-02-08 07:39:41 +08:00
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
if (table_desc->pointer != table) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
acpi_tb_put_table(table_desc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
|
|
|
|
return_VOID;
|
2009-02-08 07:39:41 +08:00
|
|
|
}
|
2013-10-29 09:30:10 +08:00
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_put_table)
|
2006-10-03 12:00:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
2007-02-03 00:48:18 +08:00
|
|
|
* FUNCTION: acpi_get_table_by_index
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2007-02-03 00:48:18 +08:00
|
|
|
* PARAMETERS: table_index - Table index
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
* out_table - Where the pointer to the table is returned
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* RETURN: Status and pointer to the requested table
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* DESCRIPTION: Obtain a table by an index into the global table list. Used
|
|
|
|
* internally also.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_status status;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:19 +08:00
|
|
|
/* Parameter validation */
|
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
if (!out_table) {
|
2007-02-03 00:48:19 +08:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
/*
|
|
|
|
* Note that the following line is required by some OSPMs, they only
|
|
|
|
* check if the returned table is NULL instead of the returned status
|
|
|
|
* to determined if this function is succeeded.
|
|
|
|
*/
|
|
|
|
*out_table = NULL;
|
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
/* Validate index */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-04-27 11:16:14 +08:00
|
|
|
if (table_index >= acpi_gbl_root_table_list.current_table_count) {
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
status = AE_BAD_PARAMETER;
|
|
|
|
goto unlock_and_exit;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
status =
|
|
|
|
acpi_tb_get_table(&acpi_gbl_root_table_list.tables[table_index],
|
|
|
|
out_table);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
unlock_and_exit:
|
2007-02-03 00:48:18 +08:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
|
ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel
ACPICA commit cac6790954d4d752a083e6122220b8a22febcd07
This patch back ports Linux acpi_get_table_with_size() and
early_acpi_os_unmap_memory() into ACPICA upstream to reduce divergences.
The 2 APIs are used by Linux as table management APIs for long time, it
contains a hidden logic that during the early stage, the mapped tables
should be unmapped before the early stage ends.
During the early stage, tables are handled by the following sequence:
acpi_get_table_with_size();
parse the table
early_acpi_os_unmap_memory();
During the late stage, tables are handled by the following sequence:
acpi_get_table();
parse the table
Linux uses acpi_gbl_permanent_mmap to distinguish the early stage and the
late stage.
The reasoning of introducing acpi_get_table_with_size() is: ACPICA will
remember the early mapped pointer in acpi_get_table() and Linux isn't able to
prevent ACPICA from using the wrong early mapped pointer during the late
stage as there is no API provided from ACPICA to be an inverse of
acpi_get_table() to forget the early mapped pointer.
But how ACPICA can work with the early/late stage requirement? Inside of
ACPICA, tables are ensured to be remained in "INSTALLED" state during the
early stage, and they are carefully not transitioned to "VALIDATED" state
until the late stage. So the same logic is in fact implemented inside of
ACPICA in a different way. The gap is only that the feature is not provided
to the OSPMs in an accessible external API style.
It then is possible to fix the gap by providing an inverse of
acpi_get_table() from ACPICA, so that the two Linux sequences can be
combined:
acpi_get_table();
parse the table
acpi_put_table();
In order to work easier with the current Linux code, acpi_get_table() and
acpi_put_table() is implemented in a usage counting based style:
1. When the usage count of the table is increased from 0 to 1, table is
mapped and .Pointer is set with the mapping address (VALIDATED);
2. When the usage count of the table is decreased from 1 to 0, .Pointer
is unset and the mapping address is unmapped (INVALIDATED).
So that we can deploy the new APIs to Linux with minimal effort by just
invoking acpi_get_table() in acpi_get_table_with_size() and invoking
acpi_put_table() in early_acpi_os_unmap_memory(). Lv Zheng.
Link: https://github.com/acpica/acpica/commit/cac67909
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-12-14 15:04:25 +08:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-10 23:06:38 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_install_table_handler
|
|
|
|
*
|
2012-07-12 09:40:10 +08:00
|
|
|
* PARAMETERS: handler - Table event handler
|
|
|
|
* context - Value passed to the handler on each event
|
2008-04-10 23:06:38 +08:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* DESCRIPTION: Install a global table event handler.
|
2008-04-10 23:06:38 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2013-01-12 23:29:38 +08:00
|
|
|
acpi_install_table_handler(acpi_table_handler handler, void *context)
|
2008-04-10 23:06:38 +08:00
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE(acpi_install_table_handler);
|
|
|
|
|
|
|
|
if (!handler) {
|
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't allow more than one handler */
|
|
|
|
|
|
|
|
if (acpi_gbl_table_handler) {
|
|
|
|
status = AE_ALREADY_EXISTS;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the handler */
|
|
|
|
|
|
|
|
acpi_gbl_table_handler = handler;
|
|
|
|
acpi_gbl_table_handler_context = context;
|
|
|
|
|
2013-10-29 09:30:02 +08:00
|
|
|
cleanup:
|
2008-04-10 23:06:38 +08:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_remove_table_handler
|
|
|
|
*
|
2012-07-12 09:40:10 +08:00
|
|
|
* PARAMETERS: handler - Table event handler that was installed
|
2008-04-10 23:06:38 +08:00
|
|
|
* previously.
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2013-04-12 08:24:53 +08:00
|
|
|
* DESCRIPTION: Remove a table event handler
|
2008-04-10 23:06:38 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
2013-01-12 23:29:38 +08:00
|
|
|
acpi_status acpi_remove_table_handler(acpi_table_handler handler)
|
2008-04-10 23:06:38 +08:00
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE(acpi_remove_table_handler);
|
|
|
|
|
|
|
|
status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that the installed handler is the same */
|
|
|
|
|
|
|
|
if (!handler || handler != acpi_gbl_table_handler) {
|
|
|
|
status = AE_BAD_PARAMETER;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the handler */
|
|
|
|
|
|
|
|
acpi_gbl_table_handler = NULL;
|
|
|
|
|
2013-10-29 09:30:02 +08:00
|
|
|
cleanup:
|
2008-04-10 23:06:38 +08:00
|
|
|
(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)
|