/******************************************************************************
*
* Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
* Address Spaces.
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* 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.
*/
#define EXPORT_ACPI_INTERFACES
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
#include "acevents.h"
ACPI_MODULE_NAME ("evxfregn")
/*******************************************************************************
*
* FUNCTION: AcpiInstallAddressSpaceHandler
*
* PARAMETERS: Device - Handle for the device
* SpaceId - The address space ID
* Handler - Address of the handler
* Setup - Address of the setup function
* Context - Value passed to the handler on each access
*
* RETURN: Status
*
* DESCRIPTION: Install a handler for all OpRegions of a given SpaceId.
*
* NOTE: This function should only be called after AcpiEnableSubsystem has
* been called. This is because any _REG methods associated with the Space ID
* are executed here, and these methods can only be safely executed after
* the default handlers have been installed and the hardware has been
* initialized (via AcpiEnableSubsystem.)
*
******************************************************************************/
void *Context)
{
/* Parameter validation */
if (!Device)
{
}
if (ACPI_FAILURE (Status))
{
}
/* Convert and validate the device handle */
if (!Node)
{
goto UnlockAndExit;
}
/* Install the handler for all Regions for this Space ID */
if (ACPI_FAILURE (Status))
{
goto UnlockAndExit;
}
/* Run all _REG methods for this address space */
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
/*******************************************************************************
*
* FUNCTION: AcpiRemoveAddressSpaceHandler
*
* PARAMETERS: Device - Handle for the device
* SpaceId - The address space ID
* Handler - Address of the handler
*
* RETURN: Status
*
* DESCRIPTION: Remove a previously installed handler.
*
******************************************************************************/
{
/* Parameter validation */
if (!Device)
{
}
if (ACPI_FAILURE (Status))
{
}
/* Convert and validate the device handle */
if (!Node ||
(Node != AcpiGbl_RootNode)))
{
goto UnlockAndExit;
}
/* Make sure the internal object exists */
if (!ObjDesc)
{
goto UnlockAndExit;
}
/* Find the address handler the user requested */
while (HandlerObj)
{
/* We have a handler, see if user requested this one */
{
/* Handler must be the same as the installed handler */
{
goto UnlockAndExit;
}
/* Matched SpaceId, first dereference this in the Regions */
"Removing address handler %p(%p) for region %s "
"on Device %p(%p)\n",
/* Walk the handler's region list */
while (RegionObj)
{
/*
* First disassociate the handler from the region.
*
* NOTE: this doesn't mean that the region goes away
* The region is just inaccessible as indicated to
* the _REG method
*/
/*
* Walk the list: Just grab the head because the
* DetachRegion removed the previous head.
*/
}
/* Remove this Handler object from the list */
/* Now we can delete the handler object */
goto UnlockAndExit;
}
/* Walk the linked list of handlers */
}
/* The handler does not exist */
"Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n",
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}