^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: nsinit - namespace initialization
^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) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _COMPONENT ACPI_NAMESPACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ACPI_MODULE_NAME("nsinit")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) acpi_ns_init_one_object(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) u32 level, void *context, void **return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) acpi_ns_init_one_device(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) u32 nesting_level, void *context, void **return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) acpi_ns_find_ini_methods(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u32 nesting_level, void *context, void **return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^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) * FUNCTION: acpi_ns_initialize_objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * PARAMETERS: None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * DESCRIPTION: Walk the entire namespace and perform any necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * initialization on the objects found therein
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) acpi_status acpi_ns_initialize_objects(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct acpi_init_walk_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ACPI_FUNCTION_TRACE(ns_initialize_objects);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) "[Init] Completing Initialization of ACPI Objects\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) "**** Starting initialization of namespace objects ****\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "Final data object initialization: "));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* Clear the info block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) memset(&info, 0, sizeof(struct acpi_init_walk_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* Walk entire namespace from the supplied root */
^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) * TBD: will become ACPI_TYPE_PACKAGE as this type object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * is now the only one that supports deferred initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * (forward references).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ACPI_UINT32_MAX, acpi_ns_init_one_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) NULL, &info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) "Namespace contains %u (0x%X) objects\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) info.object_count, info.object_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) "%u Control Methods found\n%u Op Regions found\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) info.method_count, info.op_region_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^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_ns_initialize_devices
^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: acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * This means running _INI on all present devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * Note: We install PCI config space handler on region access,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * not here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) acpi_status acpi_ns_initialize_devices(u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct acpi_device_walk_info info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) acpi_handle handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ACPI_FUNCTION_TRACE(ns_initialize_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (!(flags & ACPI_NO_DEVICE_INIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) "[Init] Initializing ACPI Devices\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Init counters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) info.device_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) info.num_STA = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) info.num_INI = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) "Initializing Device/Processor/Thermal objects "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) "and executing _INI/_STA methods:\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* Tree analysis: find all subtrees that contain _INI methods */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ACPI_UINT32_MAX, FALSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) acpi_ns_find_ini_methods, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) &info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Allocate the evaluation information block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) info.evaluate_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (!info.evaluate_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^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) * Execute the "global" _INI method that may appear at the root.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * This support is provided for Windows compatibility (Vista+) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * is not part of the ACPI specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) info.evaluate_info->prefix_node = acpi_gbl_root_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) info.evaluate_info->relative_pathname = METHOD_NAME__INI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) info.evaluate_info->parameters = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) status = acpi_ns_evaluate(info.evaluate_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) info.num_INI++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Execute \_SB._INI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * There appears to be a strict order requirement for \_SB._INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * which should be evaluated before any _REG evaluations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) status = acpi_get_handle(NULL, "\\_SB", &handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) memset(info.evaluate_info, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) sizeof(struct acpi_evaluate_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) info.evaluate_info->prefix_node = handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) info.evaluate_info->relative_pathname =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) METHOD_NAME__INI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) info.evaluate_info->parameters = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) status = acpi_ns_evaluate(info.evaluate_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) info.num_INI++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * Run all _REG methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * Note: Any objects accessed by the _REG methods will be automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * initialized, even if they contain executable AML (see the call to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * acpi_ns_initialize_objects below).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * Note: According to the ACPI specification, we actually needn't execute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * _REG for system_memory/system_io operation regions, but for PCI_Config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * operation regions, it is required to evaluate _REG for those on a PCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * root bus that doesn't contain _BBN object. So this code is kept here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * in order not to break things.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) "[Init] Executing _REG OpRegion methods\n"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) status = acpi_ev_initialize_op_regions();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) goto error_exit;
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (!(flags & ACPI_NO_DEVICE_INIT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /* Walk namespace to execute all _INIs on present devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ACPI_UINT32_MAX, FALSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) acpi_ns_init_one_device, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) &info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * Any _OSI requests should be completed by now. If the BIOS has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * requested any Windows OSI strings, we will always truncate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * I/O addresses to 16 bits -- for Windows compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (acpi_gbl_osi_data >= ACPI_OSI_WIN_2000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) acpi_gbl_truncate_io_addresses = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ACPI_FREE(info.evaluate_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) goto error_exit;
^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) ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) " Executed %u _INI methods requiring %u _STA executions "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) "(examined %u objects)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) info.num_INI, info.num_STA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) info.device_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) ACPI_EXCEPTION((AE_INFO, status, "During device initialization"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) return_ACPI_STATUS(status);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * FUNCTION: acpi_ns_init_one_package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * PARAMETERS: obj_handle - Node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * level - Current nesting level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * context - Not used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * return_value - Not used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * within the namespace. Used during dynamic load of an SSDT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) acpi_ns_init_one_package(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) u32 level, void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct acpi_namespace_node *node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) (struct acpi_namespace_node *)obj_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) obj_desc = acpi_ns_get_attached_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /* Exit if package is already initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (obj_desc->package.flags & AOPOBJ_DATA_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return (AE_OK);
^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) status = acpi_ds_get_package_arguments(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) acpi_ut_walk_package_tree(obj_desc, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) acpi_ds_init_package_element, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) obj_desc->package.flags |= AOPOBJ_DATA_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * FUNCTION: acpi_ns_init_one_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * PARAMETERS: obj_handle - Node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * level - Current nesting level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * context - Points to a init info struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * return_value - Not used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * within the namespace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * Currently, the only objects that require initialization are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * 1) Methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * 2) Op Regions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) acpi_ns_init_one_object(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) u32 level, void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) acpi_object_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct acpi_init_walk_info *info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) (struct acpi_init_walk_info *)context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct acpi_namespace_node *node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) (struct acpi_namespace_node *)obj_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) ACPI_FUNCTION_NAME(ns_init_one_object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) info->object_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) /* And even then, we are only interested in a few object types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) type = acpi_ns_get_type(obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) obj_desc = acpi_ns_get_attached_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) /* Increment counters for object types we are looking for */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) info->op_region_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) case ACPI_TYPE_BUFFER_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) info->field_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) case ACPI_TYPE_LOCAL_BANK_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) info->field_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) info->buffer_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) info->package_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /* No init required, just exit now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* If the object is already initialized, nothing else to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) /* Must lock the interpreter before executing AML code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) acpi_ex_enter_interpreter();
^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) * Only initialization of Package objects can be deferred, in order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * to support forward references.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) case ACPI_TYPE_LOCAL_BANK_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /* TBD: bank_fields do not require deferred init, remove this code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) info->field_init++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) status = acpi_ds_get_bank_field_arguments(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /* Complete the initialization/resolution of the package object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) info->package_init++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) acpi_ns_init_one_package(obj_handle, level, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) /* No other types should get here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) status = AE_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) "Opcode is not deferred [%4.4s] (%s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) acpi_ut_get_node_name(node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) acpi_ut_get_type_name(type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) break;
^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) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) "Could not execute arguments for [%4.4s] (%s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) acpi_ut_get_node_name(node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) acpi_ut_get_type_name(type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^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) * We ignore errors from above, and always return OK, since we don't want
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * to abort the walk on any single error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) acpi_ex_exit_interpreter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) return (AE_OK);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * FUNCTION: acpi_ns_find_ini_methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) * PARAMETERS: acpi_walk_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * RETURN: acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) * device/processor/thermal objects, and marks the entire subtree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) * with a SUBTREE_HAS_INI flag. This flag is used during the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) * subsequent device initialization walk to avoid entire subtrees
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) * that do not contain an _INI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) acpi_ns_find_ini_methods(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) u32 nesting_level, void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) struct acpi_device_walk_info *info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) ACPI_CAST_PTR(struct acpi_device_walk_info, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct acpi_namespace_node *parent_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /* Keep count of device/processor/thermal objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) if ((node->type == ACPI_TYPE_DEVICE) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) (node->type == ACPI_TYPE_PROCESSOR) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) (node->type == ACPI_TYPE_THERMAL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) info->device_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /* We are only looking for methods named _INI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) if (!ACPI_COMPARE_NAMESEG(node->name.ascii, METHOD_NAME__INI)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) * The only _INI methods that we care about are those that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * present under Device, Processor, and Thermal objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) parent_node = node->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) switch (parent_node->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) /* Mark parent and bubble up the INI present flag to the root */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) while (parent_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) parent_node->flags |= ANOBJ_SUBTREE_HAS_INI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) parent_node = parent_node->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * FUNCTION: acpi_ns_init_one_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * PARAMETERS: acpi_walk_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * RETURN: acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * DESCRIPTION: This is called once per device soon after ACPI is enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * to initialize each device. It determines if the device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * present, and if so, calls _INI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) *
^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) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) acpi_ns_init_one_device(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) u32 nesting_level, void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) struct acpi_device_walk_info *walk_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) ACPI_CAST_PTR(struct acpi_device_walk_info, context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) struct acpi_evaluate_info *info = walk_info->evaluate_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) struct acpi_namespace_node *device_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) ACPI_FUNCTION_TRACE(ns_init_one_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) /* We are interested in Devices, Processors and thermal_zones only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) device_node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if ((device_node->type != ACPI_TYPE_DEVICE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) (device_node->type != ACPI_TYPE_PROCESSOR) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) (device_node->type != ACPI_TYPE_THERMAL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) * Because of an earlier namespace analysis, all subtrees that contain an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * _INI method are tagged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * If this device subtree does not contain any _INI methods, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * can exit now and stop traversing this entire subtree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) if (!(device_node->flags & ANOBJ_SUBTREE_HAS_INI)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) return_ACPI_STATUS(AE_CTRL_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * Run _STA to determine if this device is present and functioning. We
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * must know this information for two important reasons (from ACPI spec):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * 1) We can only run _INI if the device is present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * 2) We must abort the device tree walk on this subtree if the device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * not present and is not functional (we will not examine the children)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * The _STA method is not required to be present under the device, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) * assume the device is present if _STA does not exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) (ACPI_TYPE_METHOD, device_node, METHOD_NAME__STA));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) status = acpi_ut_execute_STA(device_node, &flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) /* Ignore error and move on to next device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) * Flags == -1 means that _STA was not found. In this case, we assume that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) * the device is both present and functional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) * From the ACPI spec, description of _STA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) * "If a device object (including the processor object) does not have an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) * _STA object, then OSPM assumes that all of the above bits are set (in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * other words, the device is present, ..., and functioning)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) if (flags != ACPI_UINT32_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) walk_info->num_STA++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) * Examine the PRESENT and FUNCTIONING status bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * Note: ACPI spec does not seem to specify behavior for the present but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * not functioning case, so we assume functioning if present.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) /* Device is not present, we must examine the Functioning bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (flags & ACPI_STA_DEVICE_FUNCTIONING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) * Device is not present but is "functioning". In this case,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) * we will not run _INI, but we continue to examine the children
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) * of this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * From the ACPI spec, description of _STA: (note - no mention
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * of whether to run _INI or not on the device in question)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * "_STA may return bit 0 clear (not present) with bit 3 set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * (device is functional). This case is used to indicate a valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * device for which no device driver should be loaded (for example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * a bridge device.) Children of this device may be present and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * valid. OSPM should continue enumeration below a device whose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * _STA returns this bit combination"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * Device is not present and is not functioning. We must abort the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * walk of this subtree immediately -- don't look at the children
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) * of such a device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * From the ACPI spec, description of _INI:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) * "If the _STA method indicates that the device is not present,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * OSPM will not run the _INI and will not examine the children
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) * of the device for _INI methods"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) return_ACPI_STATUS(AE_CTRL_DEPTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * The device is present or is assumed present if no _STA exists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) * Run the _INI if it exists (not required to exist)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) * Note: We know there is an _INI within this subtree, but it may not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) * under this particular device, it may be lower in the branch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if (!ACPI_COMPARE_NAMESEG(device_node->name.ascii, "_SB_") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) device_node->parent != acpi_gbl_root_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) (ACPI_TYPE_METHOD, device_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) METHOD_NAME__INI));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) memset(info, 0, sizeof(struct acpi_evaluate_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) info->prefix_node = device_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) info->relative_pathname = METHOD_NAME__INI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) info->parameters = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) info->flags = ACPI_IGNORE_RETURN_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) status = acpi_ns_evaluate(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) walk_info->num_INI++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) #ifdef ACPI_DEBUG_OUTPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) else if (status != AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) /* Ignore error and move on to next device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) char *scope_name =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) acpi_ns_get_normalized_pathname(device_node, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) "during %s._INI execution",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) scope_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) ACPI_FREE(scope_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) /* Ignore errors from above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) * The _INI method has been run if present; call the Global Initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) * Handler for this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) if (acpi_gbl_init_handler) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) acpi_gbl_init_handler(device_node, ACPI_INIT_DEVICE_INI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) }