// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /****************************************************************************** * * Module Name: evregion - Operation Region support * * Copyright (C) 2000 - 2023, Intel Corp. * *****************************************************************************/ #include <acpi/acpi.h> #include "accommon.h" #include "acevents.h" #include "acnamesp.h" #include "acinterp.h" #define _COMPONENT … ACPI_MODULE_NAME("evregion") extern u8 acpi_gbl_default_address_spaces[]; /* Local prototypes */ static void acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node, acpi_adr_space_type space_id); static acpi_status acpi_ev_reg_run(acpi_handle obj_handle, u32 level, void *context, void **return_value); /******************************************************************************* * * FUNCTION: acpi_ev_initialize_op_regions * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Execute _REG methods for all Operation Regions that have * an installed default region handler. * ******************************************************************************/ acpi_status acpi_ev_initialize_op_regions(void) { … } /******************************************************************************* * * FUNCTION: acpi_ev_address_space_dispatch * * PARAMETERS: region_obj - Internal region object * field_obj - Corresponding field. Can be NULL. * function - Read or Write operation * region_offset - Where in the region to read or write * bit_width - Field width in bits (8, 16, 32, or 64) * value - Pointer to in or out value, must be * a full 64-bit integer * * RETURN: Status * * DESCRIPTION: Dispatch an address space or operation region access to * a previously installed handler. * * NOTE: During early initialization, we always install the default region * handlers for Memory, I/O and PCI_Config. This ensures that these operation * region address spaces are always available as per the ACPI specification. * This is especially needed in order to support the execution of * module-level AML code during loading of the ACPI tables. * ******************************************************************************/ acpi_status acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, union acpi_operand_object *field_obj, u32 function, u32 region_offset, u32 bit_width, u64 *value) { … } /******************************************************************************* * * FUNCTION: acpi_ev_detach_region * * PARAMETERS: region_obj - Region Object * acpi_ns_is_locked - Namespace Region Already Locked? * * RETURN: None * * DESCRIPTION: Break the association between the handler and the region * this is a two way association. * ******************************************************************************/ void acpi_ev_detach_region(union acpi_operand_object *region_obj, u8 acpi_ns_is_locked) { … } /******************************************************************************* * * FUNCTION: acpi_ev_attach_region * * PARAMETERS: handler_obj - Handler Object * region_obj - Region Object * acpi_ns_is_locked - Namespace Region Already Locked? * * RETURN: None * * DESCRIPTION: Create the association between the handler and the region * this is a two way association. * ******************************************************************************/ acpi_status acpi_ev_attach_region(union acpi_operand_object *handler_obj, union acpi_operand_object *region_obj, u8 acpi_ns_is_locked) { … } /******************************************************************************* * * FUNCTION: acpi_ev_execute_reg_method * * PARAMETERS: region_obj - Region object * function - Passed to _REG: On (1) or Off (0) * * RETURN: Status * * DESCRIPTION: Execute _REG method for a region * ******************************************************************************/ acpi_status acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) { … } /******************************************************************************* * * FUNCTION: acpi_ev_execute_reg_methods * * PARAMETERS: node - Namespace node for the device * max_depth - Depth to which search for _REG * space_id - The address space ID * function - Passed to _REG: On (1) or Off (0) * * RETURN: None * * DESCRIPTION: Run all _REG methods for the input Space ID; * Note: assumes namespace is locked, or system init time. * ******************************************************************************/ void acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, u32 max_depth, acpi_adr_space_type space_id, u32 function) { … } /******************************************************************************* * * FUNCTION: acpi_ev_reg_run * * PARAMETERS: walk_namespace callback * * DESCRIPTION: Run _REG method for region objects of the requested spaceID * ******************************************************************************/ static acpi_status acpi_ev_reg_run(acpi_handle obj_handle, u32 level, void *context, void **return_value) { … } /******************************************************************************* * * FUNCTION: acpi_ev_execute_orphan_reg_method * * PARAMETERS: device_node - Namespace node for an ACPI device * space_id - The address space ID * * RETURN: None * * DESCRIPTION: Execute an "orphan" _REG method that appears under an ACPI * device. This is a _REG method that has no corresponding region * within the device's scope. ACPI tables depending on these * "orphan" _REG methods have been seen for both EC and GPIO * Operation Regions. Presumably the Windows ACPI implementation * always calls the _REG method independent of the presence of * an actual Operation Region with the correct address space ID. * * MUTEX: Assumes the namespace is locked * ******************************************************************************/ static void acpi_ev_execute_orphan_reg_method(struct acpi_namespace_node *device_node, acpi_adr_space_type space_id) { … }