^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Module Name: tbxface - ACPI table-oriented external interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define EXPORT_ACPI_INTERFACES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define _COMPONENT ACPI_TABLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ACPI_MODULE_NAME("tbxface")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * FUNCTION: acpi_allocate_root_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * PARAMETERS: initial_table_count - Size of initial_table_array, in number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * struct acpi_table_desc structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * acpi_initialize_tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) acpi_status acpi_allocate_root_table(u32 initial_table_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) acpi_gbl_root_table_list.max_table_count = initial_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return (acpi_tb_resize_root_table_list());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * FUNCTION: acpi_initialize_tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * PARAMETERS: initial_table_array - Pointer to an array of pre-allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * struct acpi_table_desc structures. If NULL, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * array is dynamically allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * initial_table_count - Size of initial_table_array, in number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * struct acpi_table_desc structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * allow_resize - Flag to tell Table Manager if resize of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * pre-allocated array is allowed. Ignored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * if initial_table_array is NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * NOTE: Allows static allocation of the initial table array in order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * to avoid the use of dynamic memory in confined environments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * such as the kernel boot sequence where it may not be available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * If the host OS memory managers are initialized, use NULL for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * initial_table_array, and the table will be dynamically allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) acpi_status ACPI_INIT_FUNCTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) acpi_initialize_tables(struct acpi_table_desc *initial_table_array,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u32 initial_table_count, u8 allow_resize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) acpi_physical_address rsdp_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ACPI_FUNCTION_TRACE(acpi_initialize_tables);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * Setup the Root Table Array and allocate the table array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * if requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (!initial_table_array) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) status = acpi_allocate_root_table(initial_table_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /* Root Table Array has been statically allocated by the host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) memset(initial_table_array, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) (acpi_size)initial_table_count *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) sizeof(struct acpi_table_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) acpi_gbl_root_table_list.tables = initial_table_array;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) acpi_gbl_root_table_list.max_table_count = initial_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (allow_resize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) acpi_gbl_root_table_list.flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ACPI_ROOT_ALLOW_RESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Get the address of the RSDP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) rsdp_address = acpi_os_get_root_pointer();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (!rsdp_address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return_ACPI_STATUS(AE_NOT_FOUND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * Get the root table (RSDT or XSDT) and extract all entries to the local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * Root Table Array. This array contains the information of the RSDT/XSDT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * in a common, more usable format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) status = acpi_tb_parse_root_table(rsdp_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_tables)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * FUNCTION: acpi_reallocate_root_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * root list from the previously provided scratch area. Should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * be called once dynamic memory allocation is available in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) acpi_status ACPI_INIT_FUNCTION acpi_reallocate_root_table(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct acpi_table_desc *table_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u32 i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * If there are tables unverified, it is required to reallocate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * root table list to clean up invalid table entries. Otherwise only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * reallocate the root table list if the host provided a static buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * for the table array in the call to acpi_initialize_tables().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if ((acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) acpi_gbl_enable_table_validation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return_ACPI_STATUS(AE_SUPPORT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * Ensure OS early boot logic, which is required by some hosts. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * table state is reported to be wrong, developers should fix the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * issue by invoking acpi_put_table() for the reported table during the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * early stage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) table_desc = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (table_desc->pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) "Table [%4.4s] is not invalidated during early boot stage",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) table_desc->signature.ascii));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (!acpi_gbl_enable_table_validation) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * Now it's safe to do full table validation. We can do deferred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * table initialization here once the flag is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) acpi_gbl_enable_table_validation = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) for (i = 0; i < acpi_gbl_root_table_list.current_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) table_desc = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (!(table_desc->flags & ACPI_TABLE_IS_VERIFIED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) acpi_tb_verify_temp_table(table_desc, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) &j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) acpi_tb_uninstall_table(table_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) status = acpi_tb_resize_root_table_list();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ACPI_EXPORT_SYMBOL_INIT(acpi_reallocate_root_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * FUNCTION: acpi_get_table_header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * PARAMETERS: signature - ACPI signature of needed table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * instance - Which instance (for SSDTs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * out_table_header - The pointer to the where the table header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * RETURN: Status and a copy of the table header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * DESCRIPTION: Finds and returns an ACPI table header. Caller provides the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * memory where a copy of the header is to be returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * (fixed length).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) acpi_get_table_header(char *signature,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) u32 instance, struct acpi_table_header *out_table_header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct acpi_table_header *header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!signature || !out_table_header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /* Walk the root table list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (!ACPI_COMPARE_NAMESEG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) (&(acpi_gbl_root_table_list.tables[i].signature),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) signature)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (++j < instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (!acpi_gbl_root_table_list.tables[i].pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if ((acpi_gbl_root_table_list.tables[i].flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ACPI_TABLE_ORIGIN_MASK) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) header =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) acpi_os_map_memory(acpi_gbl_root_table_list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) tables[i].address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (!header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) memcpy(out_table_header, header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) sizeof(struct acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) acpi_os_unmap_memory(header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) sizeof(struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return (AE_NOT_FOUND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) memcpy(out_table_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) acpi_gbl_root_table_list.tables[i].pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) sizeof(struct acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return (AE_NOT_FOUND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ACPI_EXPORT_SYMBOL(acpi_get_table_header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * FUNCTION: acpi_get_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * PARAMETERS: signature - ACPI signature of needed table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * instance - Which instance (for SSDTs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * out_table - Where the pointer to the table is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * RETURN: Status and pointer to the requested table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * RSDT/XSDT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * Note that an early stage acpi_get_table() call must be paired
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * with an early stage acpi_put_table() call. otherwise the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * pointer mapped by the early stage mapping implementation may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * erroneously unmapped by the late stage unmapping implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * in an acpi_put_table() invoked during the late stage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) acpi_get_table(char *signature,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) u32 instance, struct acpi_table_header ** out_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) u32 j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) acpi_status status = AE_NOT_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) struct acpi_table_desc *table_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) if (!signature || !out_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * Note that the following line is required by some OSPMs, they only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * check if the returned table is NULL instead of the returned status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * to determined if this function is succeeded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) *out_table = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /* Walk the root table list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) table_desc = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (!ACPI_COMPARE_NAMESEG(&table_desc->signature, signature)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (++j < instance) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) status = acpi_tb_get_table(table_desc, out_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) ACPI_EXPORT_SYMBOL(acpi_get_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * FUNCTION: acpi_put_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * PARAMETERS: table - The pointer to the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) * RETURN: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * DESCRIPTION: Release a table returned by acpi_get_table() and its clones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * Note that it is not safe if this function was invoked after an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * uninstallation happened to the original table descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * Currently there is no OSPMs' requirement to handle such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * situations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void acpi_put_table(struct acpi_table_header *table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct acpi_table_desc *table_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) ACPI_FUNCTION_TRACE(acpi_put_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) if (!table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) /* Walk the root table list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) table_desc = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (table_desc->pointer != table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) acpi_tb_put_table(table_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) ACPI_EXPORT_SYMBOL(acpi_put_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) * FUNCTION: acpi_get_table_by_index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * PARAMETERS: table_index - Table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) * out_table - Where the pointer to the table is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * RETURN: Status and pointer to the requested table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * DESCRIPTION: Obtain a table by an index into the global table list. Used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * internally also.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) /* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if (!out_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * Note that the following line is required by some OSPMs, they only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * check if the returned table is NULL instead of the returned status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * to determined if this function is succeeded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) *out_table = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /* Validate index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) if (table_index >= acpi_gbl_root_table_list.current_table_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) acpi_tb_get_table(&acpi_gbl_root_table_list.tables[table_index],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) out_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) * FUNCTION: acpi_install_table_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) * PARAMETERS: handler - Table event handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) * context - Value passed to the handler on each event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * DESCRIPTION: Install a global table event handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) acpi_install_table_handler(acpi_table_handler handler, void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) ACPI_FUNCTION_TRACE(acpi_install_table_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (!handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /* Don't allow more than one handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if (acpi_gbl_table_handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) status = AE_ALREADY_EXISTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) /* Install the handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) acpi_gbl_table_handler = handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) acpi_gbl_table_handler_context = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * FUNCTION: acpi_remove_table_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * PARAMETERS: handler - Table event handler that was installed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * previously.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * DESCRIPTION: Remove a table event handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) acpi_status acpi_remove_table_handler(acpi_table_handler handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) ACPI_FUNCTION_TRACE(acpi_remove_table_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) /* Make sure that the installed handler is the same */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (!handler || handler != acpi_gbl_table_handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) status = AE_BAD_PARAMETER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) /* Remove the handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) acpi_gbl_table_handler = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)