evrgnini.c revision 8313524a0d466f451a62709aaedf988d8257b21c
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/****************************************************************************** 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Module Name: evrgnini- ACPI address_space (op_region) init 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *****************************************************************************/ 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 84a90c7e86202f46fa9af011bdbcdf36e355d1721Bob Moore * Copyright (C) 2000 - 2006, R. Byron Moore 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All rights reserved. 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Redistribution and use in source and binary forms, with or without 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * modification, are permitted provided that the following conditions 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * are met: 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1. Redistributions of source code must retain the above copyright 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * notice, this list of conditions, and the following disclaimer, 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * without modification. 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2. Redistributions in binary form must reproduce at minimum a disclaimer 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * substantially similar to the "NO WARRANTY" disclaimer below 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ("Disclaimer") and any redistribution must be conditioned upon 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * including a substantially similar Disclaimer requirement for further 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * binary redistribution. 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3. Neither the names of the above-listed copyright holders nor the names 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * of any contributors may be used to endorse or promote products derived 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * from this software without specific prior written permission. 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alternatively, this software may be distributed under the terms of the 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * GNU General Public License ("GPL") version 2 as published by the Free 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Software Foundation. 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NO WARRANTY 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * POSSIBILITY OF SUCH DAMAGES. 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acpi.h> 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acevents.h> 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acnamesp.h> 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _COMPONENT ACPI_EVENTS 494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen BrownACPI_MODULE_NAME("evrgnini") 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_system_memory_region_setup 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Handle - Region we are interested in 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Function - Start or stop 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handler_context - Address space handler context 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * region_context - Region specific context 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 6244f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Setup a system_memory operation region 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 664be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_system_memory_region_setup(acpi_handle handle, 674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 function, 684be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *handler_context, void **region_context) 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *region_desc = 714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (union acpi_operand_object *)handle; 724be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_mem_space_context *local_region_context; 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 744be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE("ev_system_memory_region_setup"); 751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (function == ACPI_REGION_DEACTIVATE) { 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (*region_context) { 788313524a0d466f451a62709aaedf988d8257b21cBob Moore ACPI_FREE(*region_context); 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = NULL; 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Create a new context */ 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 864be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown local_region_context = 878313524a0d466f451a62709aaedf988d8257b21cBob Moore ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_mem_space_context)); 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!(local_region_context)) { 894be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Save the region length and address for use in the handler */ 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds local_region_context->length = region_desc->region.length; 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds local_region_context->address = region_desc->region.address; 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = local_region_context; 984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_io_space_region_setup 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Handle - Region we are interested in 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Function - Start or stop 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handler_context - Address space handler context 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * region_context - Region specific context 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 11244f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Setup a IO operation region 1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 1174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_io_space_region_setup(acpi_handle handle, 1184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 function, 1194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *handler_context, void **region_context) 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1214be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE("ev_io_space_region_setup"); 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (function == ACPI_REGION_DEACTIVATE) { 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = NULL; 1254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = handler_context; 1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_pci_config_region_setup 1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 13644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: Handle - Region we are interested in 1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Function - Start or stop 1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handler_context - Address space handler context 1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * region_context - Region specific context 1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 1421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 14344f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Setup a PCI_Config operation region 1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * MUTEX: Assumes namespace is not locked 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 1504be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_pci_config_region_setup(acpi_handle handle, 1514be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 function, 1524be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *handler_context, void **region_context) 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1544be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status = AE_OK; 1554be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_integer pci_value; 1564be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_pci_id *pci_id = *region_context; 1574be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *handler_obj; 1584be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_namespace_node *parent_node; 1594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_namespace_node *pci_root_node; 1604be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *region_obj = 1614be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (union acpi_operand_object *)handle; 1624be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_device_id object_hID; 1634be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown 1644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE("ev_pci_config_region_setup"); 1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds handler_obj = region_obj->region.handler; 1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!handler_obj) { 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * No installed handler. This shouldn't happen because the dispatch 1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * routine checks before we get here, but we check again just in case. 1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1724be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 1734be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown "Attempting to init a region %p, with no handler\n", 1744be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown region_obj)); 1754be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NOT_EXIST); 1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = NULL; 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (function == ACPI_REGION_DEACTIVATE) { 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (pci_id) { 1818313524a0d466f451a62709aaedf988d8257b21cBob Moore ACPI_FREE(pci_id); 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1834be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1864be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown parent_node = acpi_ns_get_parent_node(region_obj->region.node); 1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Get the _SEG and _BBN values from the device upon which the handler 1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * is installed. 1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * We need to get the _SEG and _BBN objects relative to the PCI BUS device. 1931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This is the device the handler has been registered to handle. 1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * If the address_space.Node is still pointing to the root, we need 1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * to scan upward for a PCI Root bridge and re-associate the op_region 1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handlers with that device. 2001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (handler_obj->address_space.node == acpi_gbl_root_node) { 20252fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Start search from the parent object */ 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pci_root_node = parent_node; 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds while (pci_root_node != acpi_gbl_root_node) { 2074be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 2084be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_execute_HID(pci_root_node, &object_hID); 2094be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_SUCCESS(status)) { 2106f42ccf2fc50ecee8ea170040627f268430c1648Robert Moore /* 2116f42ccf2fc50ecee8ea170040627f268430c1648Robert Moore * Got a valid _HID string, check if this is a PCI root. 2126f42ccf2fc50ecee8ea170040627f268430c1648Robert Moore * New for ACPI 3.0: check for a PCI Express root also. 2136f42ccf2fc50ecee8ea170040627f268430c1648Robert Moore */ 2144be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (! 2154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (ACPI_STRNCMP 2164be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (object_hID.value, PCI_ROOT_HID_STRING, 2174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown sizeof(PCI_ROOT_HID_STRING)) 2184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown || 2194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown !(ACPI_STRNCMP 2204be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (object_hID.value, 2214be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown PCI_EXPRESS_ROOT_HID_STRING, 2224be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown sizeof(PCI_EXPRESS_ROOT_HID_STRING))))) 2234be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown { 22452fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Install a handler for this PCI root bridge */ 2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 2284be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); 2294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (status == AE_SAME_HANDLER) { 2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * It is OK if the handler is already installed on the root 2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * bridge. Still need to return a context object for the 2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * new PCI_Config operation region, however. 2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds status = AE_OK; 2374be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 238b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_EXCEPTION((AE_INFO, 239b8e4d89357fc434618a59c1047cac72641191805Bob Moore status, 240b8e4d89357fc434618a59c1047cac72641191805Bob Moore "Could not install pci_config handler for Root Bridge %4.4s", 241b8e4d89357fc434618a59c1047cac72641191805Bob Moore acpi_ut_get_node_name 242b8e4d89357fc434618a59c1047cac72641191805Bob Moore (pci_root_node))); 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown pci_root_node = acpi_ns_get_parent_node(pci_root_node); 2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* PCI root bridge not found, use namespace root node */ 2534be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pci_root_node = handler_obj->address_space.node; 2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * If this region is now initialized, we are done. 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (install_address_space_handler could have initialized it) 2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 2624be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 2631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Region is still not initialized. Create a new context */ 2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2678313524a0d466f451a62709aaedf988d8257b21cBob Moore pci_id = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pci_id)); 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!pci_id) { 2694be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * For PCI_Config space access, we need the segment, bus, 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * device and function numbers. Acquire them here. 2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Get the PCI device and function numbers from the _ADR object 2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * contained in the parent's scope. 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 2824be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, parent_node, 2834be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown &pci_value); 2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The default is zero, and since the allocation above zeroed 2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * the data, just do nothing on failure. 2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2894be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_SUCCESS(status)) { 2904be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value)); 2914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value)); 2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* The PCI segment number comes from the _SEG method */ 2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2964be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 2974be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node, 2984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown &pci_value); 2994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_SUCCESS(status)) { 3004be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown pci_id->segment = ACPI_LOWORD(pci_value); 3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* The PCI bus number comes from the _BBN method */ 3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3054be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 3064be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node, 3074be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown &pci_value); 3084be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_SUCCESS(status)) { 3094be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown pci_id->bus = ACPI_LOWORD(pci_value); 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Complete this device's pci_id */ 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3144be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_derive_pci_id(pci_root_node, region_obj->region.node, &pci_id); 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = pci_id; 3174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_pci_bar_region_setup 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Handle - Region we are interested in 3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Function - Start or stop 3261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handler_context - Address space handler context 3271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * region_context - Region specific context 3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 33144f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Setup a pci_bAR operation region 3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * MUTEX: Assumes namespace is not locked 3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 3384be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_pci_bar_region_setup(acpi_handle handle, 3394be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 function, 3404be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *handler_context, void **region_context) 3411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup"); 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_cmos_region_setup 3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Handle - Region we are interested in 3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Function - Start or stop 3531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handler_context - Address space handler context 3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * region_context - Region specific context 3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 35844f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Setup a CMOS operation region 3591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * MUTEX: Assumes namespace is not locked 3611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 3631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 3654be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_cmos_region_setup(acpi_handle handle, 3664be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 function, 3674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *handler_context, void **region_context) 3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3694be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE("ev_cmos_region_setup"); 3701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 3721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_default_region_setup 3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Handle - Region we are interested in 3791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Function - Start or stop 3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * handler_context - Address space handler context 3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * region_context - Region specific context 3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 3841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 38544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Default region initialization 3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 3904be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_default_region_setup(acpi_handle handle, 3914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 function, 3924be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *handler_context, void **region_context) 3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 3944be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE("ev_default_region_setup"); 3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (function == ACPI_REGION_DEACTIVATE) { 3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = NULL; 3984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 3991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *region_context = handler_context; 4001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4024be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 4041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 4061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ev_initialize_region 4081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: region_obj - Region we are initializing 4101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * acpi_ns_locked - Is namespace locked? 4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Initializes the region, finds any _REG methods and saves them 4151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * for execution at a later time 4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Get the appropriate address space handler for a newly 4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * created region. 4191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This also performs address space specific initialization. For 4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * example, PCI regions must have an _ADR object that contains 4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * a PCI address in the scope of the definition. This address is 4231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * required to perform an access to PCI config space. 4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 4284be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ev_initialize_region(union acpi_operand_object *region_obj, 4294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u8 acpi_ns_locked) 4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 4314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *handler_obj; 4324be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *obj_desc; 4334be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_adr_space_type space_id; 4344be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_namespace_node *node; 4354be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 4364be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_namespace_node *method_node; 4374be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG; 4384be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *region_obj2; 4391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4404be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked); 4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!region_obj) { 4434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_BAD_PARAMETER); 4441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) { 4474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4504be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown region_obj2 = acpi_ns_get_secondary_object(region_obj); 4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!region_obj2) { 4524be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NOT_EXIST); 4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4554be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown node = acpi_ns_get_parent_node(region_obj->region.node); 4561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds space_id = region_obj->region.space_id; 4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Setup defaults */ 4591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds region_obj->region.handler = NULL; 4611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds region_obj2->extra.method_REG = NULL; 4621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds region_obj->common.flags &= ~(AOPOBJ_SETUP_COMPLETE); 4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED; 4641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Find any "_REG" method associated with this region definition */ 4661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ns_search_node(*reg_name_ptr, node, 4684be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_TYPE_METHOD, &method_node); 4694be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_SUCCESS(status)) { 4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 4711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The _REG method is optional and there can be only one per region 4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * definition. This will be executed when the handler is attached 4731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * or removed 4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds region_obj2->extra.method_REG = method_node; 4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 4791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The following loop depends upon the root Node having no parent 4801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ie: acpi_gbl_root_node->parent_entry being set to NULL 4811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds while (node) { 48352fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Check to see if a handler exists */ 4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds handler_obj = NULL; 4874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown obj_desc = acpi_ns_get_attached_object(node); 4881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (obj_desc) { 48952fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 4901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Can only be a handler if the object exists */ 4911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (node->type) { 4931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_DEVICE: 4941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds handler_obj = obj_desc->device.handler; 4961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_PROCESSOR: 4991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds handler_obj = obj_desc->processor.handler; 5011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 5021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_THERMAL: 5041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds handler_obj = obj_desc->thermal_zone.handler; 5061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 5071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 5091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Ignore other objects */ 5101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 5111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds while (handler_obj) { 51452fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 5151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Is this handler of the correct type? */ 5161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (handler_obj->address_space.space_id == 5184be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown space_id) { 51952fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 5201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Found correct handler */ 5211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5224be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 5234be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown "Found handler %p for region %p in obj %p\n", 5244be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown handler_obj, 5254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown region_obj, 5264be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown obj_desc)); 5271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5284be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 5294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ev_attach_region(handler_obj, 5304be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown region_obj, 5314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ns_locked); 5321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 5341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Tell all users that this region is usable by running the _REG 5351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * method 5361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 5371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (acpi_ns_locked) { 5384be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 5394be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_release_mutex 5404be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (ACPI_MTX_NAMESPACE); 5414be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 5424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS 5434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (status); 5441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5474be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 5484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ev_execute_reg_method 5494be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (region_obj, 1); 5501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (acpi_ns_locked) { 5524be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 5534be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_acquire_mutex 5544be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (ACPI_MTX_NAMESPACE); 5554be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 5564be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS 5574be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (status); 5581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5614be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 5621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Try next handler in the list */ 5651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds handler_obj = handler_obj->address_space.next; 5671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 5711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This node does not have the handler we need; 5721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Pop up one level 5731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 5744be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown node = acpi_ns_get_parent_node(node); 5751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* If we get here, there is no handler for this region */ 5781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5794be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 5804be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown "No handler for region_type %s(%X) (region_obj %p)\n", 5814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_get_region_name(space_id), space_id, 5824be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown region_obj)); 5831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5844be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NOT_EXIST); 5851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 586