^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: tbxfload - Table load/unload 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 "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define _COMPONENT ACPI_TABLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) ACPI_MODULE_NAME("tbxfload")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * FUNCTION: acpi_load_tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
^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_INIT_FUNCTION acpi_load_tables(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ACPI_FUNCTION_TRACE(acpi_load_tables);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Install the default operation region handlers. These are the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * handlers that are defined by the ACPI specification to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * "always accessible" -- namely, system_memory, system_IO, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * PCI_Config. This also means that no _REG methods need to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * run for these address spaces. We need to have these handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * installed before any AML code can be executed, especially any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * module-level code (11/2015).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * Note that we allow OSPMs to install their own region handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * between acpi_initialize_subsystem() and acpi_load_tables() to use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * their customized default region handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) status = acpi_ev_install_region_handlers();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) "During Region initialization"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* Load the namespace from the tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) status = acpi_tb_load_namespace();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* Don't let single failures abort the load */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (status == AE_CTRL_TERMINATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) status = AE_OK;
^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) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) "While loading namespace from ACPI tables"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * Initialize the objects in the namespace that remain uninitialized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * This runs the executable AML that may be part of the declaration of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * these name objects:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * operation_regions, buffer_fields, Buffers, and Packages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) status = acpi_ns_initialize_objects();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) acpi_gbl_namespace_initialized = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ACPI_EXPORT_SYMBOL_INIT(acpi_load_tables)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * FUNCTION: acpi_tb_load_namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * the RSDT/XSDT.
^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) acpi_status acpi_tb_load_namespace(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct acpi_table_header *new_dsdt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct acpi_table_desc *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) u32 tables_loaded = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u32 tables_failed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ACPI_FUNCTION_TRACE(tb_load_namespace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * Load the namespace. The DSDT is required, but any SSDT and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * PSDT tables are optional. Verify the DSDT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) table = &acpi_gbl_root_table_list.tables[acpi_gbl_dsdt_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (!acpi_gbl_root_table_list.current_table_count ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) !ACPI_COMPARE_NAMESEG(table->signature.ascii, ACPI_SIG_DSDT) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) ACPI_FAILURE(acpi_tb_validate_table(table))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) status = AE_NO_ACPI_TABLES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) goto unlock_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * Save the DSDT pointer for simple access. This is the mapped memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * address. We must take care here because the address of the .Tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * array can change dynamically as tables are loaded at run-time. Note:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * .Pointer field is not validated until after call to acpi_tb_validate_table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) acpi_gbl_DSDT = table->pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * Optionally copy the entire DSDT to local memory (instead of simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * mapping it.) There are some BIOSs that corrupt or replace the original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * DSDT, creating the need for this option. Default is FALSE, do not copy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * the DSDT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (acpi_gbl_copy_dsdt_locally) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) new_dsdt = acpi_tb_copy_dsdt(acpi_gbl_dsdt_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (new_dsdt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) acpi_gbl_DSDT = new_dsdt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * Save the original DSDT header for detection of table corruption
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * and/or replacement of the DSDT from outside the OS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) memcpy(&acpi_gbl_original_dsdt_header, acpi_gbl_DSDT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) sizeof(struct acpi_table_header));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* Load and parse tables */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) status = acpi_ns_load_table(acpi_gbl_dsdt_index, acpi_gbl_root_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) ACPI_EXCEPTION((AE_INFO, status, "[DSDT] table load failed"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) tables_failed++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) tables_loaded++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) table = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (!table->address ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) (!ACPI_COMPARE_NAMESEG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) (table->signature.ascii, ACPI_SIG_SSDT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) && !ACPI_COMPARE_NAMESEG(table->signature.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ACPI_SIG_PSDT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) && !ACPI_COMPARE_NAMESEG(table->signature.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ACPI_SIG_OSDT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) || ACPI_FAILURE(acpi_tb_validate_table(table))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /* Ignore errors while loading tables, get as many as possible */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) status = acpi_ns_load_table(i, acpi_gbl_root_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) "(%4.4s:%8.8s) while loading table",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) table->signature.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) table->pointer->oem_table_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) tables_failed++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) "Table [%4.4s:%8.8s] (id FF) - Table namespace load failed\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) table->signature.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) table->pointer->oem_table_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) tables_loaded++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!tables_failed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) ACPI_INFO(("%u ACPI AML tables successfully acquired and loaded", tables_loaded));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) "%u table load failures, %u successful",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) tables_failed, tables_loaded));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* Indicate at least one failure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) status = AE_CTRL_TERMINATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #ifdef ACPI_APPLICATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) unlock_and_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * FUNCTION: acpi_install_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * PARAMETERS: address - Address of the ACPI table to be installed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * physical - Whether the address is a physical table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * address or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * DESCRIPTION: Dynamically install an ACPI table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * Note: This function should only be invoked after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * acpi_initialize_tables() and before acpi_load_tables().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) acpi_status ACPI_INIT_FUNCTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) acpi_install_table(acpi_physical_address address, u8 physical)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) u32 table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) ACPI_FUNCTION_TRACE(acpi_install_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (physical) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) status = acpi_tb_install_standard_table(address, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) FALSE, FALSE, &table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) ACPI_EXPORT_SYMBOL_INIT(acpi_install_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * FUNCTION: acpi_load_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * PARAMETERS: table - Pointer to a buffer containing the ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * table to be loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * table_idx - Pointer to a u32 for storing the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * index, might be NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * DESCRIPTION: Dynamically load an ACPI table from the caller's buffer. Must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * be a valid ACPI table with a valid ACPI table header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * Note1: Mainly intended to support hotplug addition of SSDTs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * Note2: Does not copy the incoming table. User is responsible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * to ensure that the table is not deleted or unmapped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) acpi_status acpi_load_table(struct acpi_table_header *table, u32 *table_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) u32 table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) ACPI_FUNCTION_TRACE(acpi_load_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (!table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return_ACPI_STATUS(AE_BAD_PARAMETER);
^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) /* Install the table and load it into the namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) ACPI_INFO(("Host-directed Dynamic ACPI Table Load:"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) status = acpi_tb_install_and_load_table(ACPI_PTR_TO_PHYSADDR(table),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) FALSE, &table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if (table_idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) *table_idx = table_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /* Complete the initialization/resolution of new objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) acpi_ns_initialize_objects();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) ACPI_EXPORT_SYMBOL(acpi_load_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * FUNCTION: acpi_unload_parent_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * PARAMETERS: object - Handle to any namespace object owned by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * the table to be unloaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * DESCRIPTION: Via any namespace object within an SSDT or OEMx table, unloads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * the table and deletes all namespace objects associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * that table. Unloading of the DSDT is not allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * Note: Mainly intended to support hotplug removal of SSDTs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) acpi_status acpi_unload_parent_table(acpi_handle object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct acpi_namespace_node *node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ACPI_CAST_PTR(struct acpi_namespace_node, object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) acpi_status status = AE_NOT_EXIST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) acpi_owner_id owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) ACPI_FUNCTION_TRACE(acpi_unload_parent_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) /* Parameter validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (!object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) return_ACPI_STATUS(AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) * The node owner_id is currently the same as the parent table ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * However, this could change in the future.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) owner_id = node->owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) if (!owner_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) /* owner_id==0 means DSDT is the owner. DSDT cannot be unloaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) return_ACPI_STATUS(AE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /* Must acquire the table lock during this operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) /* Find the table in the global table list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (owner_id != acpi_gbl_root_table_list.tables[i].owner_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * Allow unload of SSDT and OEMx tables only. Do not allow unload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * of the DSDT. No other types of tables should get here, since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * only these types can contain AML and thus are the only types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * that can create namespace objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) if (ACPI_COMPARE_NAMESEG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) (acpi_gbl_root_table_list.tables[i].signature.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) ACPI_SIG_DSDT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) status = acpi_tb_unload_table(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) ACPI_EXPORT_SYMBOL(acpi_unload_parent_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * FUNCTION: acpi_unload_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * PARAMETERS: table_index - Index as returned by acpi_load_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * DESCRIPTION: Via the table_index representing an SSDT or OEMx table, unloads
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * the table and deletes all namespace objects associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * that table. Unloading of the DSDT is not allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * Note: Mainly intended to support hotplug removal of SSDTs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) acpi_status acpi_unload_table(u32 table_index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) ACPI_FUNCTION_TRACE(acpi_unload_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (table_index == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) /* table_index==1 means DSDT is the owner. DSDT cannot be unloaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) return_ACPI_STATUS(AE_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) status = acpi_tb_unload_table(table_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) ACPI_EXPORT_SYMBOL(acpi_unload_table)