2005-04-16 22:20:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: evrgnini- ACPI address_space (op_region) init
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
2006-01-13 21:22:00 +00:00
|
|
|
* Copyright (C) 2000 - 2006, R. Byron Moore
|
2005-04-16 22:20:36 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
|
|
|
#include <acpi/acevents.h>
|
|
|
|
#include <acpi/acnamesp.h>
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_EVENTS
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_MODULE_NAME("evrgnini")
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_system_memory_region_setup
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
|
|
|
* Function - Start or stop
|
|
|
|
* handler_context - Address space handler context
|
|
|
|
* region_context - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Setup a system_memory operation region
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_system_memory_region_setup(acpi_handle handle,
|
|
|
|
u32 function,
|
|
|
|
void *handler_context, void **region_context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *region_desc =
|
|
|
|
(union acpi_operand_object *)handle;
|
|
|
|
struct acpi_mem_space_context *local_region_context;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_TRACE("ev_system_memory_region_setup");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (function == ACPI_REGION_DEACTIVATE) {
|
|
|
|
if (*region_context) {
|
ACPI: ACPICA 20060331
Implemented header file support for the following
additional ACPI tables: ASF!, BOOT, CPEP, DBGP, MCFG, SPCR,
SPMI, TCPA, and WDRT. With this support, all current and
known ACPI tables are now defined in the ACPICA headers and
are available for use by device drivers and other software.
Implemented support to allow tables that contain ACPI
names with invalid characters to be loaded. Previously,
this would cause the table load to fail, but since
there are several known cases of such tables on
existing machines, this change was made to enable
ACPI support for them. Also, this matches the
behavior of the Microsoft ACPI implementation.
https://bugzilla.novell.com/show_bug.cgi?id=147621
Fixed a couple regressions introduced during the memory
optimization in the 20060317 release. The namespace
node definition required additional reorganization and
an internal datatype that had been changed to 8-bit was
restored to 32-bit. (Valery Podrezov)
Fixed a problem where a null pointer passed to
acpi_ut_delete_generic_state() could be passed through
to acpi_os_release_object which is unexpected. Such
null pointers are now trapped and ignored, matching
the behavior of the previous implementation before the
deployment of acpi_os_release_object(). (Valery Podrezov,
Fiodor Suietov)
Fixed a memory mapping leak during the deletion of
a SystemMemory operation region where a cached memory
mapping was not deleted. This became a noticeable problem
for operation regions that are defined within frequently
used control methods. (Dana Meyers)
Reorganized the ACPI table header files into two main
files: one for the ACPI tables consumed by the ACPICA core,
and another for the miscellaneous ACPI tables that are
consumed by the drivers and other software. The various
FADT definitions were merged into one common section and
three different tables (ACPI 1.0, 1.0+, and 2.0)
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-03-31 05:00:00 +00:00
|
|
|
local_region_context =
|
|
|
|
(struct acpi_mem_space_context *)*region_context;
|
|
|
|
|
|
|
|
/* Delete a cached mapping if present */
|
|
|
|
|
|
|
|
if (local_region_context->mapped_length) {
|
|
|
|
acpi_os_unmap_memory(local_region_context->
|
|
|
|
mapped_logical_address,
|
|
|
|
local_region_context->
|
|
|
|
mapped_length);
|
|
|
|
}
|
|
|
|
ACPI_FREE(local_region_context);
|
2005-04-16 22:20:36 +00:00
|
|
|
*region_context = NULL;
|
|
|
|
}
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a new context */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
local_region_context =
|
2006-10-03 04:00:00 +00:00
|
|
|
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_mem_space_context));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!(local_region_context)) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the region length and address for use in the handler */
|
|
|
|
|
|
|
|
local_region_context->length = region_desc->region.length;
|
|
|
|
local_region_context->address = region_desc->region.address;
|
|
|
|
|
|
|
|
*region_context = local_region_context;
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_io_space_region_setup
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
|
|
|
* Function - Start or stop
|
|
|
|
* handler_context - Address space handler context
|
|
|
|
* region_context - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Setup a IO operation region
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_io_space_region_setup(acpi_handle handle,
|
|
|
|
u32 function,
|
|
|
|
void *handler_context, void **region_context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_TRACE("ev_io_space_region_setup");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (function == ACPI_REGION_DEACTIVATE) {
|
|
|
|
*region_context = NULL;
|
2005-08-05 04:44:28 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
*region_context = handler_context;
|
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_pci_config_region_setup
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2005-04-16 22:20:36 +00:00
|
|
|
* Function - Start or stop
|
|
|
|
* handler_context - Address space handler context
|
|
|
|
* region_context - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Setup a PCI_Config operation region
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is not locked
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_pci_config_region_setup(acpi_handle handle,
|
|
|
|
u32 function,
|
|
|
|
void *handler_context, void **region_context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status status = AE_OK;
|
|
|
|
acpi_integer pci_value;
|
|
|
|
struct acpi_pci_id *pci_id = *region_context;
|
|
|
|
union acpi_operand_object *handler_obj;
|
|
|
|
struct acpi_namespace_node *parent_node;
|
|
|
|
struct acpi_namespace_node *pci_root_node;
|
|
|
|
union acpi_operand_object *region_obj =
|
|
|
|
(union acpi_operand_object *)handle;
|
|
|
|
struct acpi_device_id object_hID;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE("ev_pci_config_region_setup");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
handler_obj = region_obj->region.handler;
|
|
|
|
if (!handler_obj) {
|
|
|
|
/*
|
|
|
|
* No installed handler. This shouldn't happen because the dispatch
|
|
|
|
* routine checks before we get here, but we check again just in case.
|
|
|
|
*/
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
|
|
|
|
"Attempting to init a region %p, with no handler\n",
|
|
|
|
region_obj));
|
|
|
|
return_ACPI_STATUS(AE_NOT_EXIST);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*region_context = NULL;
|
|
|
|
if (function == ACPI_REGION_DEACTIVATE) {
|
|
|
|
if (pci_id) {
|
2006-10-03 04:00:00 +00:00
|
|
|
ACPI_FREE(pci_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
parent_node = acpi_ns_get_parent_node(region_obj->region.node);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the _SEG and _BBN values from the device upon which the handler
|
|
|
|
* is installed.
|
|
|
|
*
|
|
|
|
* We need to get the _SEG and _BBN objects relative to the PCI BUS device.
|
|
|
|
* This is the device the handler has been registered to handle.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the address_space.Node is still pointing to the root, we need
|
|
|
|
* to scan upward for a PCI Root bridge and re-associate the op_region
|
|
|
|
* handlers with that device.
|
|
|
|
*/
|
|
|
|
if (handler_obj->address_space.node == acpi_gbl_root_node) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Start search from the parent object */
|
|
|
|
|
|
|
|
pci_root_node = parent_node;
|
|
|
|
while (pci_root_node != acpi_gbl_root_node) {
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ut_execute_HID(pci_root_node, &object_hID);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-05-13 04:00:00 +00:00
|
|
|
/*
|
|
|
|
* Got a valid _HID string, check if this is a PCI root.
|
|
|
|
* New for ACPI 3.0: check for a PCI Express root also.
|
|
|
|
*/
|
2005-08-05 04:44:28 +00:00
|
|
|
if (!
|
|
|
|
(ACPI_STRNCMP
|
|
|
|
(object_hID.value, PCI_ROOT_HID_STRING,
|
|
|
|
sizeof(PCI_ROOT_HID_STRING))
|
|
|
|
||
|
|
|
|
!(ACPI_STRNCMP
|
|
|
|
(object_hID.value,
|
|
|
|
PCI_EXPRESS_ROOT_HID_STRING,
|
|
|
|
sizeof(PCI_EXPRESS_ROOT_HID_STRING)))))
|
|
|
|
{
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Install a handler for this PCI root bridge */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_install_address_space_handler((acpi_handle) pci_root_node, ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (status == AE_SAME_HANDLER) {
|
|
|
|
/*
|
|
|
|
* It is OK if the handler is already installed on the root
|
|
|
|
* bridge. Still need to return a context object for the
|
|
|
|
* new PCI_Config operation region, however.
|
|
|
|
*/
|
|
|
|
status = AE_OK;
|
2005-08-05 04:44:28 +00:00
|
|
|
} else {
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_EXCEPTION((AE_INFO,
|
|
|
|
status,
|
|
|
|
"Could not install pci_config handler for Root Bridge %4.4s",
|
|
|
|
acpi_ut_get_node_name
|
|
|
|
(pci_root_node)));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
pci_root_node = acpi_ns_get_parent_node(pci_root_node);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PCI root bridge not found, use namespace root node */
|
2005-08-05 04:44:28 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
pci_root_node = handler_obj->address_space.node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this region is now initialized, we are done.
|
|
|
|
* (install_address_space_handler could have initialized it)
|
|
|
|
*/
|
|
|
|
if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Region is still not initialized. Create a new context */
|
|
|
|
|
2006-10-03 04:00:00 +00:00
|
|
|
pci_id = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pci_id));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!pci_id) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_NO_MEMORY);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For PCI_Config space access, we need the segment, bus,
|
|
|
|
* device and function numbers. Acquire them here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the PCI device and function numbers from the _ADR object
|
|
|
|
* contained in the parent's scope.
|
|
|
|
*/
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, parent_node,
|
|
|
|
&pci_value);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The default is zero, and since the allocation above zeroed
|
|
|
|
* the data, just do nothing on failure.
|
|
|
|
*/
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
|
|
|
|
pci_id->function = ACPI_LOWORD(ACPI_LODWORD(pci_value));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The PCI segment number comes from the _SEG method */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ut_evaluate_numeric_object(METHOD_NAME__SEG, pci_root_node,
|
|
|
|
&pci_value);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
pci_id->segment = ACPI_LOWORD(pci_value);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The PCI bus number comes from the _BBN method */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ut_evaluate_numeric_object(METHOD_NAME__BBN, pci_root_node,
|
|
|
|
&pci_value);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
pci_id->bus = ACPI_LOWORD(pci_value);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Complete this device's pci_id */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_os_derive_pci_id(pci_root_node, region_obj->region.node, &pci_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
*region_context = pci_id;
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_pci_bar_region_setup
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
|
|
|
* Function - Start or stop
|
|
|
|
* handler_context - Address space handler context
|
|
|
|
* region_context - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Setup a pci_bAR operation region
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is not locked
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_pci_bar_region_setup(acpi_handle handle,
|
|
|
|
u32 function,
|
|
|
|
void *handler_context, void **region_context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_TRACE("ev_pci_bar_region_setup");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_cmos_region_setup
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
|
|
|
* Function - Start or stop
|
|
|
|
* handler_context - Address space handler context
|
|
|
|
* region_context - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Setup a CMOS operation region
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is not locked
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_cmos_region_setup(acpi_handle handle,
|
|
|
|
u32 function,
|
|
|
|
void *handler_context, void **region_context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_TRACE("ev_cmos_region_setup");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_default_region_setup
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
|
|
|
* Function - Start or stop
|
|
|
|
* handler_context - Address space handler context
|
|
|
|
* region_context - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Default region initialization
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_default_region_setup(acpi_handle handle,
|
|
|
|
u32 function,
|
|
|
|
void *handler_context, void **region_context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_TRACE("ev_default_region_setup");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (function == ACPI_REGION_DEACTIVATE) {
|
|
|
|
*region_context = NULL;
|
2005-08-05 04:44:28 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
*region_context = handler_context;
|
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_initialize_region
|
|
|
|
*
|
|
|
|
* PARAMETERS: region_obj - Region we are initializing
|
|
|
|
* acpi_ns_locked - Is namespace locked?
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initializes the region, finds any _REG methods and saves them
|
|
|
|
* for execution at a later time
|
|
|
|
*
|
|
|
|
* Get the appropriate address space handler for a newly
|
|
|
|
* created region.
|
|
|
|
*
|
|
|
|
* This also performs address space specific initialization. For
|
|
|
|
* example, PCI regions must have an _ADR object that contains
|
|
|
|
* a PCI address in the scope of the definition. This address is
|
|
|
|
* required to perform an access to PCI config space.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ev_initialize_region(union acpi_operand_object *region_obj,
|
|
|
|
u8 acpi_ns_locked)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *handler_obj;
|
|
|
|
union acpi_operand_object *obj_desc;
|
|
|
|
acpi_adr_space_type space_id;
|
|
|
|
struct acpi_namespace_node *node;
|
|
|
|
acpi_status status;
|
|
|
|
struct acpi_namespace_node *method_node;
|
|
|
|
acpi_name *reg_name_ptr = (acpi_name *) METHOD_NAME__REG;
|
|
|
|
union acpi_operand_object *region_obj2;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_TRACE_U32("ev_initialize_region", acpi_ns_locked);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!region_obj) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_BAD_PARAMETER);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (region_obj->common.flags & AOPOBJ_OBJECT_INITIALIZED) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
region_obj2 = acpi_ns_get_secondary_object(region_obj);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!region_obj2) {
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_NOT_EXIST);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
node = acpi_ns_get_parent_node(region_obj->region.node);
|
2005-04-16 22:20:36 +00:00
|
|
|
space_id = region_obj->region.space_id;
|
|
|
|
|
|
|
|
/* Setup defaults */
|
|
|
|
|
|
|
|
region_obj->region.handler = NULL;
|
|
|
|
region_obj2->extra.method_REG = NULL;
|
|
|
|
region_obj->common.flags &= ~(AOPOBJ_SETUP_COMPLETE);
|
|
|
|
region_obj->common.flags |= AOPOBJ_OBJECT_INITIALIZED;
|
|
|
|
|
|
|
|
/* Find any "_REG" method associated with this region definition */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ns_search_node(*reg_name_ptr, node,
|
|
|
|
ACPI_TYPE_METHOD, &method_node);
|
|
|
|
if (ACPI_SUCCESS(status)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* The _REG method is optional and there can be only one per region
|
|
|
|
* definition. This will be executed when the handler is attached
|
|
|
|
* or removed
|
|
|
|
*/
|
|
|
|
region_obj2->extra.method_REG = method_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following loop depends upon the root Node having no parent
|
|
|
|
* ie: acpi_gbl_root_node->parent_entry being set to NULL
|
|
|
|
*/
|
|
|
|
while (node) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Check to see if a handler exists */
|
|
|
|
|
|
|
|
handler_obj = NULL;
|
2005-08-05 04:44:28 +00:00
|
|
|
obj_desc = acpi_ns_get_attached_object(node);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (obj_desc) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Can only be a handler if the object exists */
|
|
|
|
|
|
|
|
switch (node->type) {
|
|
|
|
case ACPI_TYPE_DEVICE:
|
|
|
|
|
|
|
|
handler_obj = obj_desc->device.handler;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_PROCESSOR:
|
|
|
|
|
|
|
|
handler_obj = obj_desc->processor.handler;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_THERMAL:
|
|
|
|
|
|
|
|
handler_obj = obj_desc->thermal_zone.handler;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Ignore other objects */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (handler_obj) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Is this handler of the correct type? */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
if (handler_obj->address_space.space_id ==
|
|
|
|
space_id) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Found correct handler */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
|
|
|
|
"Found handler %p for region %p in obj %p\n",
|
|
|
|
handler_obj,
|
|
|
|
region_obj,
|
|
|
|
obj_desc));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ev_attach_region(handler_obj,
|
|
|
|
region_obj,
|
|
|
|
acpi_ns_locked);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Tell all users that this region is usable by running the _REG
|
|
|
|
* method
|
|
|
|
*/
|
|
|
|
if (acpi_ns_locked) {
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ut_release_mutex
|
|
|
|
(ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS
|
|
|
|
(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ev_execute_reg_method
|
|
|
|
(region_obj, 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (acpi_ns_locked) {
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
|
|
|
acpi_ut_acquire_mutex
|
|
|
|
(ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS
|
|
|
|
(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Try next handler in the list */
|
|
|
|
|
|
|
|
handler_obj = handler_obj->address_space.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This node does not have the handler we need;
|
|
|
|
* Pop up one level
|
|
|
|
*/
|
2005-08-05 04:44:28 +00:00
|
|
|
node = acpi_ns_get_parent_node(node);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If we get here, there is no handler for this region */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
|
|
|
|
"No handler for region_type %s(%X) (region_obj %p)\n",
|
|
|
|
acpi_ut_get_region_name(space_id), space_id,
|
|
|
|
region_obj));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(AE_NOT_EXIST);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|