2000-10-28 05:01:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2000-12-01 09:36:25 +00:00
|
|
|
* Module Name: evrgnini- ACPI AddressSpace (OpRegion) init
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-01-13 16:12:34 +00:00
|
|
|
/*
|
2013-01-17 21:32:03 +00:00
|
|
|
* Copyright (C) 2000 - 2013, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2011-01-13 16:12:34 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define __EVRGNINI_C__
|
|
|
|
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acpi.h"
|
2009-06-01 21:02:40 +00:00
|
|
|
#include "accommon.h"
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acevents.h"
|
|
|
|
#include "acnamesp.h"
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_EVENTS
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("evrgnini")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Local prototypes */
|
|
|
|
|
|
|
|
static BOOLEAN
|
|
|
|
AcpiEvIsPciRootBridge (
|
|
|
|
ACPI_NAMESPACE_NODE *Node);
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvSystemMemoryRegionSetup
|
|
|
|
*
|
2004-12-01 23:14:10 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2002-07-09 17:51:31 +00:00
|
|
|
* Function - Start or stop
|
2000-10-28 05:01:06 +00:00
|
|
|
* HandlerContext - Address space handler context
|
|
|
|
* RegionContext - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Setup a SystemMemory operation region
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvSystemMemoryRegionSetup (
|
|
|
|
ACPI_HANDLE Handle,
|
|
|
|
UINT32 Function,
|
|
|
|
void *HandlerContext,
|
|
|
|
void **RegionContext)
|
|
|
|
{
|
2002-03-16 02:18:13 +00:00
|
|
|
ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle;
|
|
|
|
ACPI_MEM_SPACE_CONTEXT *LocalRegionContext;
|
|
|
|
|
2002-07-09 17:51:31 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (Function == ACPI_REGION_DEACTIVATE)
|
|
|
|
{
|
|
|
|
if (*RegionContext)
|
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext;
|
|
|
|
|
|
|
|
/* Delete a cached mapping if present */
|
|
|
|
|
|
|
|
if (LocalRegionContext->MappedLength)
|
|
|
|
{
|
|
|
|
AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress,
|
|
|
|
LocalRegionContext->MappedLength);
|
|
|
|
}
|
|
|
|
ACPI_FREE (LocalRegionContext);
|
2000-10-28 05:01:06 +00:00
|
|
|
*RegionContext = NULL;
|
|
|
|
}
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
2002-07-09 17:51:31 +00:00
|
|
|
/* Create a new context */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT));
|
2002-03-16 02:18:13 +00:00
|
|
|
if (!(LocalRegionContext))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
2002-03-16 02:18:13 +00:00
|
|
|
/* Save the region length and address for use in the handler */
|
|
|
|
|
|
|
|
LocalRegionContext->Length = RegionDesc->Region.Length;
|
|
|
|
LocalRegionContext->Address = RegionDesc->Region.Address;
|
|
|
|
|
|
|
|
*RegionContext = LocalRegionContext;
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvIoSpaceRegionSetup
|
|
|
|
*
|
2004-12-01 23:14:10 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2002-07-09 17:51:31 +00:00
|
|
|
* Function - Start or stop
|
2000-10-28 05:01:06 +00:00
|
|
|
* HandlerContext - Address space handler context
|
|
|
|
* RegionContext - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Setup a IO operation region
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvIoSpaceRegionSetup (
|
|
|
|
ACPI_HANDLE Handle,
|
|
|
|
UINT32 Function,
|
|
|
|
void *HandlerContext,
|
|
|
|
void **RegionContext)
|
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
if (Function == ACPI_REGION_DEACTIVATE)
|
|
|
|
{
|
|
|
|
*RegionContext = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*RegionContext = HandlerContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvPciConfigRegionSetup
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2002-07-09 17:51:31 +00:00
|
|
|
* Function - Start or stop
|
2000-10-28 05:01:06 +00:00
|
|
|
* HandlerContext - Address space handler context
|
|
|
|
* RegionContext - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Setup a PCI_Config operation region
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is not locked
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvPciConfigRegionSetup (
|
|
|
|
ACPI_HANDLE Handle,
|
|
|
|
UINT32 Function,
|
|
|
|
void *HandlerContext,
|
|
|
|
void **RegionContext)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status = AE_OK;
|
2010-01-21 20:56:18 +00:00
|
|
|
UINT64 PciValue;
|
2001-07-21 03:55:17 +00:00
|
|
|
ACPI_PCI_ID *PciId = *RegionContext;
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_OPERAND_OBJECT *HandlerObj;
|
2003-07-13 22:44:13 +00:00
|
|
|
ACPI_NAMESPACE_NODE *ParentNode;
|
|
|
|
ACPI_NAMESPACE_NODE *PciRootNode;
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_NAMESPACE_NODE *PciDeviceNode;
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle;
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
HandlerObj = RegionObj->Region.Handler;
|
2000-10-28 05:01:06 +00:00
|
|
|
if (!HandlerObj)
|
|
|
|
{
|
|
|
|
/*
|
2002-07-09 17:51:31 +00:00
|
|
|
* No installed handler. This shouldn't happen because the dispatch
|
|
|
|
* routine checks before we get here, but we check again just in case.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
|
2001-10-31 02:32:29 +00:00
|
|
|
"Attempting to init a region %p, with no handler\n", RegionObj));
|
2001-05-29 19:52:40 +00:00
|
|
|
return_ACPI_STATUS (AE_NOT_EXIST);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
*RegionContext = NULL;
|
2000-10-28 05:01:06 +00:00
|
|
|
if (Function == ACPI_REGION_DEACTIVATE)
|
|
|
|
{
|
2001-07-21 03:55:17 +00:00
|
|
|
if (PciId)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FREE (PciId);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2010-05-28 18:46:48 +00:00
|
|
|
ParentNode = RegionObj->Region.Node->Parent;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*
|
2002-07-09 17:51:31 +00:00
|
|
|
* Get the _SEG and _BBN values from the device upon which the handler
|
|
|
|
* is installed.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2002-07-09 17:51:31 +00:00
|
|
|
* 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.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2003-07-13 22:44:13 +00:00
|
|
|
* If the AddressSpace.Node is still pointing to the root, we need
|
2002-07-09 17:51:31 +00:00
|
|
|
* to scan upward for a PCI Root bridge and re-associate the OpRegion
|
|
|
|
* handlers with that device.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2003-07-13 22:44:13 +00:00
|
|
|
if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
/* Start search from the parent object */
|
|
|
|
|
|
|
|
PciRootNode = ParentNode;
|
|
|
|
while (PciRootNode != AcpiGbl_RootNode)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Get the _HID/_CID in order to detect a RootBridge */
|
|
|
|
|
|
|
|
if (AcpiEvIsPciRootBridge (PciRootNode))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Install a handler for this PCI root bridge */
|
2002-07-09 17:51:31 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiInstallAddressSpaceHandler (
|
|
|
|
(ACPI_HANDLE) PciRootNode,
|
|
|
|
ACPI_ADR_SPACE_PCI_CONFIG,
|
|
|
|
ACPI_DEFAULT_HANDLER, NULL, NULL);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
if (Status == AE_SAME_HANDLER)
|
|
|
|
{
|
|
|
|
/*
|
2009-06-01 21:02:40 +00:00
|
|
|
* 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.
|
2007-03-22 17:24:05 +00:00
|
|
|
*/
|
|
|
|
Status = AE_OK;
|
|
|
|
}
|
|
|
|
else
|
2002-07-09 17:51:31 +00:00
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXCEPTION ((AE_INFO, Status,
|
2009-06-01 21:02:40 +00:00
|
|
|
"Could not install PciConfig handler "
|
|
|
|
"for Root Bridge %4.4s",
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiUtGetNodeName (PciRootNode)));
|
2002-07-09 17:51:31 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2007-03-22 17:24:05 +00:00
|
|
|
break;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-05-28 18:46:48 +00:00
|
|
|
PciRootNode = PciRootNode->Parent;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2003-07-13 22:44:13 +00:00
|
|
|
|
|
|
|
/* PCI root bridge not found, use namespace root node */
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
PciRootNode = HandlerObj->AddressSpace.Node;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2000-12-01 09:36:25 +00:00
|
|
|
|
2001-07-21 03:55:17 +00:00
|
|
|
/*
|
2003-07-13 22:44:13 +00:00
|
|
|
* If this region is now initialized, we are done.
|
|
|
|
* (InstallAddressSpaceHandler could have initialized it)
|
2001-07-21 03:55:17 +00:00
|
|
|
*/
|
2003-07-13 22:44:13 +00:00
|
|
|
if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Region is still not initialized. Create a new context */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID));
|
2003-07-13 22:44:13 +00:00
|
|
|
if (!PciId)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
return_ACPI_STATUS (AE_NO_MEMORY);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2001-07-21 03:55:17 +00:00
|
|
|
/*
|
2009-06-01 21:02:40 +00:00
|
|
|
* For PCI_Config space access, we need the segment, bus, device and
|
|
|
|
* function numbers. Acquire them here.
|
2007-03-22 17:24:05 +00:00
|
|
|
*
|
|
|
|
* Find the parent device object. (This allows the operation region to be
|
|
|
|
* within a subscope under the device, such as a control method.)
|
2003-07-13 22:44:13 +00:00
|
|
|
*/
|
2007-03-22 17:24:05 +00:00
|
|
|
PciDeviceNode = RegionObj->Region.Node;
|
|
|
|
while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE))
|
|
|
|
{
|
2010-05-28 18:46:48 +00:00
|
|
|
PciDeviceNode = PciDeviceNode->Parent;
|
2007-03-22 17:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!PciDeviceNode)
|
|
|
|
{
|
2009-06-01 21:02:40 +00:00
|
|
|
ACPI_FREE (PciId);
|
2007-03-22 17:24:05 +00:00
|
|
|
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
|
|
|
|
}
|
2003-07-13 22:44:13 +00:00
|
|
|
|
|
|
|
/*
|
2010-09-15 20:49:34 +00:00
|
|
|
* Get the PCI device and function numbers from the _ADR object
|
|
|
|
* contained in the parent's scope.
|
2003-07-13 22:44:13 +00:00
|
|
|
*/
|
2009-06-01 21:02:40 +00:00
|
|
|
Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR,
|
|
|
|
PciDeviceNode, &PciValue);
|
2003-07-13 22:44:13 +00:00
|
|
|
|
|
|
|
/*
|
2009-06-01 21:02:40 +00:00
|
|
|
* The default is zero, and since the allocation above zeroed the data,
|
|
|
|
* just do nothing on failure.
|
2001-07-21 03:55:17 +00:00
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue));
|
|
|
|
PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue));
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
/* The PCI segment number comes from the _SEG method */
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG,
|
|
|
|
PciRootNode, &PciValue);
|
2003-07-13 22:44:13 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
|
|
|
PciId->Segment = ACPI_LOWORD (PciValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The PCI bus number comes from the _BBN method */
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN,
|
|
|
|
PciRootNode, &PciValue);
|
2003-07-13 22:44:13 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
|
|
|
PciId->Bus = ACPI_LOWORD (PciValue);
|
|
|
|
}
|
|
|
|
|
2010-09-15 20:49:34 +00:00
|
|
|
/* Complete/update the PCI ID for this device */
|
2003-07-13 22:44:13 +00:00
|
|
|
|
2010-09-15 20:49:34 +00:00
|
|
|
Status = AcpiHwDerivePciId (PciId, PciRootNode, RegionObj->Region.Node);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
ACPI_FREE (PciId);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2003-04-29 18:39:29 +00:00
|
|
|
|
2001-07-21 03:55:17 +00:00
|
|
|
*RegionContext = PciId;
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvIsPciRootBridge
|
|
|
|
*
|
|
|
|
* PARAMETERS: Node - Device node being examined
|
|
|
|
*
|
|
|
|
* RETURN: TRUE if device is a PCI/PCI-Express Root Bridge
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Determine if the input device represents a PCI Root Bridge by
|
|
|
|
* examining the _HID and _CID for the device.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static BOOLEAN
|
|
|
|
AcpiEvIsPciRootBridge (
|
|
|
|
ACPI_NAMESPACE_NODE *Node)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
2012-10-19 18:47:57 +00:00
|
|
|
ACPI_PNP_DEVICE_ID *Hid;
|
|
|
|
ACPI_PNP_DEVICE_ID_LIST *Cid;
|
2009-06-01 21:02:40 +00:00
|
|
|
UINT32 i;
|
2009-06-25 23:20:50 +00:00
|
|
|
BOOLEAN Match;
|
2007-03-22 17:24:05 +00:00
|
|
|
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* Get the _HID and check for a PCI Root Bridge */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiUtExecute_HID (Node, &Hid);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
2009-06-25 23:20:50 +00:00
|
|
|
Match = AcpiUtIsPciRootBridge (Hid->String);
|
|
|
|
ACPI_FREE (Hid);
|
|
|
|
|
|
|
|
if (Match)
|
2007-03-22 17:24:05 +00:00
|
|
|
{
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* The _HID did not match. Get the _CID and check for a PCI Root Bridge */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiUtExecute_CID (Node, &Cid);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check all _CIDs in the returned list */
|
|
|
|
|
|
|
|
for (i = 0; i < Cid->Count; i++)
|
|
|
|
{
|
2009-06-25 23:20:50 +00:00
|
|
|
if (AcpiUtIsPciRootBridge (Cid->Ids[i].String))
|
2007-03-22 17:24:05 +00:00
|
|
|
{
|
|
|
|
ACPI_FREE (Cid);
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_FREE (Cid);
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-04 23:12:13 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvPciBarRegionSetup
|
|
|
|
*
|
2004-12-01 23:14:10 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2002-07-09 17:51:31 +00:00
|
|
|
* Function - Start or stop
|
2001-10-04 23:12:13 +00:00
|
|
|
* HandlerContext - Address space handler context
|
|
|
|
* RegionContext - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Setup a PciBAR operation region
|
2001-10-04 23:12:13 +00:00
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is not locked
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvPciBarRegionSetup (
|
|
|
|
ACPI_HANDLE Handle,
|
|
|
|
UINT32 Function,
|
|
|
|
void *HandlerContext,
|
|
|
|
void **RegionContext)
|
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (EvPciBarRegionSetup);
|
2001-10-04 23:12:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvCmosRegionSetup
|
|
|
|
*
|
2004-12-01 23:14:10 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2002-07-09 17:51:31 +00:00
|
|
|
* Function - Start or stop
|
2001-10-04 23:12:13 +00:00
|
|
|
* HandlerContext - Address space handler context
|
|
|
|
* RegionContext - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Setup a CMOS operation region
|
2001-10-04 23:12:13 +00:00
|
|
|
*
|
|
|
|
* MUTEX: Assumes namespace is not locked
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvCmosRegionSetup (
|
|
|
|
ACPI_HANDLE Handle,
|
|
|
|
UINT32 Function,
|
|
|
|
void *HandlerContext,
|
|
|
|
void **RegionContext)
|
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (EvCmosRegionSetup);
|
2001-10-04 23:12:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvDefaultRegionSetup
|
|
|
|
*
|
2004-12-01 23:14:10 +00:00
|
|
|
* PARAMETERS: Handle - Region we are interested in
|
2002-07-09 17:51:31 +00:00
|
|
|
* Function - Start or stop
|
2000-10-28 05:01:06 +00:00
|
|
|
* HandlerContext - Address space handler context
|
|
|
|
* RegionContext - Region specific context
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Default region initialization
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvDefaultRegionSetup (
|
|
|
|
ACPI_HANDLE Handle,
|
|
|
|
UINT32 Function,
|
|
|
|
void *HandlerContext,
|
|
|
|
void **RegionContext)
|
|
|
|
{
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (EvDefaultRegionSetup);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
if (Function == ACPI_REGION_DEACTIVATE)
|
|
|
|
{
|
|
|
|
*RegionContext = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*RegionContext = HandlerContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiEvInitializeRegion
|
|
|
|
*
|
2002-07-09 17:51:31 +00:00
|
|
|
* PARAMETERS: RegionObj - Region we are initializing
|
|
|
|
* AcpiNsLocked - Is namespace locked?
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2009-06-01 21:02:40 +00:00
|
|
|
* This also performs address space specific initialization. For
|
2000-10-28 05:01:06 +00:00
|
|
|
* example, PCI regions must have an _ADR object that contains
|
2009-06-01 21:02:40 +00:00
|
|
|
* a PCI address in the scope of the definition. This address is
|
2000-10-28 05:01:06 +00:00
|
|
|
* required to perform an access to PCI config space.
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* MUTEX: Interpreter should be unlocked, because we may run the _REG
|
|
|
|
* method for this region.
|
|
|
|
*
|
2000-10-28 05:01:06 +00:00
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiEvInitializeRegion (
|
|
|
|
ACPI_OPERAND_OBJECT *RegionObj,
|
|
|
|
BOOLEAN AcpiNsLocked)
|
|
|
|
{
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_OPERAND_OBJECT *HandlerObj;
|
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
|
|
|
ACPI_ADR_SPACE_TYPE SpaceId;
|
|
|
|
ACPI_NAMESPACE_NODE *Node;
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_STATUS Status;
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_NAMESPACE_NODE *MethodNode;
|
|
|
|
ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG;
|
2001-11-28 04:29:40 +00:00
|
|
|
ACPI_OPERAND_OBJECT *RegionObj2;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (!RegionObj)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
|
|
|
|
if (!RegionObj2)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_NOT_EXIST);
|
|
|
|
}
|
|
|
|
|
2010-05-28 18:46:48 +00:00
|
|
|
Node = RegionObj->Region.Node->Parent;
|
2000-10-28 05:01:06 +00:00
|
|
|
SpaceId = RegionObj->Region.SpaceId;
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
/* Setup defaults */
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
RegionObj->Region.Handler = NULL;
|
2001-11-28 04:29:40 +00:00
|
|
|
RegionObj2->Extra.Method_REG = NULL;
|
|
|
|
RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
|
|
|
|
RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
/* Find any "_REG" method associated with this region definition */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiNsSearchOneScope (
|
|
|
|
*RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
|
|
|
/*
|
2002-07-09 17:51:31 +00:00
|
|
|
* The _REG method is optional and there can be only one per region
|
2009-06-01 21:02:40 +00:00
|
|
|
* definition. This will be executed when the handler is attached
|
2002-07-09 17:51:31 +00:00
|
|
|
* or removed
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2001-11-28 04:29:40 +00:00
|
|
|
RegionObj2->Extra.Method_REG = MethodNode;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-07-09 17:51:31 +00:00
|
|
|
* The following loop depends upon the root Node having no parent
|
|
|
|
* ie: AcpiGbl_RootNode->ParentEntry being set to NULL
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
|
|
|
while (Node)
|
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
/* Check to see if a handler exists */
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
HandlerObj = NULL;
|
2001-05-29 19:52:40 +00:00
|
|
|
ObjDesc = AcpiNsGetAttachedObject (Node);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (ObjDesc)
|
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
/* Can only be a handler if the object exists */
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
switch (Node->Type)
|
|
|
|
{
|
|
|
|
case ACPI_TYPE_DEVICE:
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
HandlerObj = ObjDesc->Device.Handler;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_PROCESSOR:
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
HandlerObj = ObjDesc->Processor.Handler;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_TYPE_THERMAL:
|
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
HandlerObj = ObjDesc->ThermalZone.Handler;
|
2000-10-28 05:01:06 +00:00
|
|
|
break;
|
2002-07-09 17:51:31 +00:00
|
|
|
|
2009-12-14 22:07:33 +00:00
|
|
|
case ACPI_TYPE_METHOD:
|
|
|
|
/*
|
|
|
|
* If we are executing module level code, the original
|
|
|
|
* Node's object was replaced by this Method object and we
|
|
|
|
* saved the handler in the method object.
|
|
|
|
*
|
|
|
|
* See AcpiNsExecModuleCode
|
|
|
|
*/
|
2011-01-13 16:12:34 +00:00
|
|
|
if (ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
|
2009-12-14 22:07:33 +00:00
|
|
|
{
|
2011-01-13 16:12:34 +00:00
|
|
|
HandlerObj = ObjDesc->Method.Dispatch.Handler;
|
2009-12-14 22:07:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-07-09 17:51:31 +00:00
|
|
|
default:
|
|
|
|
/* Ignore other objects */
|
|
|
|
break;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (HandlerObj)
|
|
|
|
{
|
2002-07-09 17:51:31 +00:00
|
|
|
/* Is this handler of the correct type? */
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
if (HandlerObj->AddressSpace.SpaceId == SpaceId)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2002-07-09 17:51:31 +00:00
|
|
|
/* Found correct handler */
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
|
|
|
|
"Found handler %p for region %p in obj %p\n",
|
2000-10-28 05:01:06 +00:00
|
|
|
HandlerObj, RegionObj, ObjDesc));
|
|
|
|
|
2002-07-09 17:51:31 +00:00
|
|
|
Status = AcpiEvAttachRegion (HandlerObj, RegionObj,
|
|
|
|
AcpiNsLocked);
|
2001-11-28 04:29:40 +00:00
|
|
|
|
2003-12-09 02:45:16 +00:00
|
|
|
/*
|
2009-06-01 21:02:40 +00:00
|
|
|
* Tell all users that this region is usable by
|
|
|
|
* running the _REG method
|
2003-12-09 02:45:16 +00:00
|
|
|
*/
|
|
|
|
if (AcpiNsLocked)
|
|
|
|
{
|
|
|
|
Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-13 18:18:52 +00:00
|
|
|
Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
|
2003-12-09 02:45:16 +00:00
|
|
|
|
|
|
|
if (AcpiNsLocked)
|
|
|
|
{
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (AE_OK);
|
|
|
|
}
|
|
|
|
|
2002-07-09 17:51:31 +00:00
|
|
|
/* Try next handler in the list */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
HandlerObj = HandlerObj->AddressSpace.Next;
|
2002-07-09 17:51:31 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
/* This node does not have the handler we need; Pop up one level */
|
|
|
|
|
2010-05-28 18:46:48 +00:00
|
|
|
Node = Node->Parent;
|
2002-07-09 17:51:31 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
/* If we get here, there is no handler for this region */
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
|
|
|
|
"No handler for RegionType %s(%X) (RegionObj %p)\n",
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
return_ACPI_STATUS (AE_NOT_EXIST);
|
|
|
|
}
|