diff options
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Events')
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evevent.c | 954 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evmisc.c | 486 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evregion.c | 778 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c | 557 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evsci.c | 436 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evxface.c | 769 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c | 624 | ||||
-rw-r--r-- | sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c | 515 |
8 files changed, 0 insertions, 5119 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evevent.c b/sys/contrib/dev/acpica/Subsystem/Events/evevent.c deleted file mode 100644 index 2738ea87b329f..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evevent.c +++ /dev/null @@ -1,954 +0,0 @@ -/****************************************************************************** - * - * Module Name: evevent - Fixed and General Purpose AcpiEvent - * handling and dispatch - * $Revision: 34 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include "acpi.h" -#include "achware.h" -#include "acevents.h" -#include "acnamesp.h" -#include "accommon.h" - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evevent") - - -/************************************************************************** - * - * FUNCTION: AcpiEvInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Ensures that the system control interrupt (SCI) is properly - * configured, disables SCI event sources, installs the SCI - * handler - * - *************************************************************************/ - -ACPI_STATUS -AcpiEvInitialize ( - void) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvInitialize"); - - - /* Make sure we have ACPI tables */ - - if (!AcpiGbl_DSDT) - { - DEBUG_PRINT (ACPI_WARN, ("EvInitialize: No ACPI tables present!\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - - /* Make sure the BIOS supports ACPI mode */ - - if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities()) - { - DEBUG_PRINT (ACPI_WARN, - ("EvInitialize: Only legacy mode supported!\n")); - return_ACPI_STATUS (AE_ERROR); - } - - - AcpiGbl_OriginalMode = AcpiHwGetMode(); - - /* - * Initialize the Fixed and General Purpose AcpiEvents prior. This is - * done prior to enabling SCIs to prevent interrupts from occuring - * before handers are installed. - */ - - Status = AcpiEvFixedEventInitialize (); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_FATAL, - ("EvInitialize: Unable to initialize fixed events.\n")); - return_ACPI_STATUS (Status); - } - - Status = AcpiEvGpeInitialize (); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_FATAL, - ("EvInitialize: Unable to initialize general purpose events.\n")); - return_ACPI_STATUS (Status); - } - - /* Install the SCI handler */ - - Status = AcpiEvInstallSciHandler (); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_FATAL, - ("EvInitialize: Unable to install System Control Interrupt Handler\n")); - return_ACPI_STATUS (Status); - } - - - /* Install handlers for control method GPE handlers (_Lxx, _Exx) */ - - Status = AcpiEvInitGpeControlMethods (); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_FATAL, - ("EvInitialize: Unable to initialize Gpe control methods\n")); - return_ACPI_STATUS (Status); - } - - /* Install the handler for the Global Lock */ - - Status = AcpiEvInitGlobalLockHandler (); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_FATAL, - ("EvInitialize: Unable to initialize Global Lock handler\n")); - return_ACPI_STATUS (Status); - } - - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvFixedEventInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize the Fixed AcpiEvent data structures - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvFixedEventInitialize(void) -{ - int i = 0; - - /* Initialize the structure that keeps track of fixed event handlers */ - - for (i = 0; i < NUM_FIXED_EVENTS; i++) - { - AcpiGbl_FixedEventHandlers[i].Handler = NULL; - AcpiGbl_FixedEventHandlers[i].Context = NULL; - } - - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, TMR_EN, 0); - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, GBL_EN, 0); - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, PWRBTN_EN, 0); - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, SLPBTN_EN, 0); - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RTC_EN, 0); - - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvFixedEventDetect - * - * PARAMETERS: None - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Checks the PM status register for fixed events - * - ******************************************************************************/ - -UINT32 -AcpiEvFixedEventDetect(void) -{ - UINT32 IntStatus = INTERRUPT_NOT_HANDLED; - UINT32 StatusRegister; - UINT32 EnableRegister; - - /* - * Read the fixed feature status and enable registers, as all the cases - * depend on their values. - */ - - StatusRegister = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, PM1_STS); - EnableRegister = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, PM1_EN); - - DEBUG_PRINT (TRACE_INTERRUPTS, - ("Fixed AcpiEvent Block: Enable = %08x\tStatus = %08x\n", - EnableRegister, StatusRegister)); - - - /* power management timer roll over */ - - if ((StatusRegister & ACPI_STATUS_PMTIMER) && - (EnableRegister & ACPI_ENABLE_PMTIMER)) - { - IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_PMTIMER); - } - - /* global event (BIOS want's the global lock) */ - - if ((StatusRegister & ACPI_STATUS_GLOBAL) && - (EnableRegister & ACPI_ENABLE_GLOBAL)) - { - IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_GLOBAL); - } - - /* power button event */ - - if ((StatusRegister & ACPI_STATUS_POWER_BUTTON) && - (EnableRegister & ACPI_ENABLE_POWER_BUTTON)) - { - IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_POWER_BUTTON); - } - - /* sleep button event */ - - if ((StatusRegister & ACPI_STATUS_SLEEP_BUTTON) && - (EnableRegister & ACPI_ENABLE_SLEEP_BUTTON)) - { - IntStatus |= AcpiEvFixedEventDispatch (ACPI_EVENT_SLEEP_BUTTON); - } - - return (IntStatus); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvFixedEventDispatch - * - * PARAMETERS: Event - Event type - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Clears the status bit for the requested event, calls the - * handler that previously registered for the event. - * - ******************************************************************************/ - -UINT32 -AcpiEvFixedEventDispatch ( - UINT32 Event) -{ - UINT32 RegisterId; - - /* Clear the status bit */ - - switch (Event) - { - case ACPI_EVENT_PMTIMER: - RegisterId = TMR_STS; - break; - - case ACPI_EVENT_GLOBAL: - RegisterId = GBL_STS; - break; - - case ACPI_EVENT_POWER_BUTTON: - RegisterId = PWRBTN_STS; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - RegisterId = SLPBTN_STS; - break; - - case ACPI_EVENT_RTC: - RegisterId = RTC_STS; - break; - - default: - return 0; - break; - } - - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, RegisterId, 1); - - /* - * Make sure we've got a handler. If not, report an error. - * The event is disabled to prevent further interrupts. - */ - if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) - { - RegisterId = (PM1_EN | REGISTER_BIT_ID(RegisterId)); - - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, - RegisterId, 0); - - REPORT_ERROR ( - ("EvGpeDispatch: No installed handler for fixed event [%08X]\n", - Event)); - - return (INTERRUPT_NOT_HANDLED); - } - - /* Invoke the handler */ - - return ((AcpiGbl_FixedEventHandlers[Event].Handler)( - AcpiGbl_FixedEventHandlers[Event].Context)); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvGpeInitialize - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Initialize the GPE data structures - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvGpeInitialize (void) -{ - UINT32 i; - UINT32 j; - UINT32 RegisterIndex; - UINT32 GpeNumber; - UINT16 Gpe0RegisterCount; - UINT16 Gpe1RegisterCount; - - - FUNCTION_TRACE ("EvGpeInitialize"); - - /* - * Set up various GPE counts - * - * You may ask,why are the GPE register block lengths divided by 2? - * From the ACPI 2.0 Spec, section, 4.7.1.6 General-Purpose Event - * Registers, we have, - * - * "Each register block contains two registers of equal length - * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the - * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN - * The length of the GPE1_STS and GPE1_EN registers is equal to - * half the GPE1_LEN. If a generic register block is not supported - * then its respective block pointer and block length values in the - * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need - * to be the same size." - */ - - Gpe0RegisterCount = (UINT16) DIV_2 (AcpiGbl_FADT->Gpe0BlkLen); - Gpe1RegisterCount = (UINT16) DIV_2 (AcpiGbl_FADT->Gpe1BlkLen); - AcpiGbl_GpeRegisterCount = Gpe0RegisterCount + Gpe1RegisterCount; - - if (!AcpiGbl_GpeRegisterCount) - { - REPORT_WARNING (("Zero GPEs are defined in the FADT\n")); - return_ACPI_STATUS (AE_OK); - } - - /* - * Allocate the Gpe information block - */ - - AcpiGbl_GpeRegisters = AcpiCmCallocate (AcpiGbl_GpeRegisterCount * - sizeof (ACPI_GPE_REGISTERS)); - if (!AcpiGbl_GpeRegisters) - { - DEBUG_PRINT (ACPI_ERROR, - ("Could not allocate the GpeRegisters block\n")); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * Allocate the Gpe dispatch handler block - * There are eight distinct GP events per register. - * Initialization to zeros is sufficient - */ - - AcpiGbl_GpeInfo = AcpiCmCallocate (MUL_8 (AcpiGbl_GpeRegisterCount) * - sizeof (ACPI_GPE_LEVEL_INFO)); - if (!AcpiGbl_GpeInfo) - { - AcpiCmFree (AcpiGbl_GpeRegisters); - DEBUG_PRINT (ACPI_ERROR, ("Could not allocate the GpeInfo block\n")); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Set the Gpe validation table to GPE_INVALID */ - - MEMSET (AcpiGbl_GpeValid, (int) ACPI_GPE_INVALID, NUM_GPE); - - /* - * Initialize the Gpe information and validation blocks. A goal of these - * blocks is to hide the fact that there are two separate GPE register sets - * In a given block, the status registers occupy the first half, and - * the enable registers occupy the second half. - */ - - /* GPE Block 0 */ - - RegisterIndex = 0; - - for (i = 0; i < Gpe0RegisterCount; i++) - { - AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr = - (UINT16) (ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) + i); - - AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr = - (UINT16) (ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) + i + Gpe0RegisterCount); - - AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = (UINT8) MUL_8 (i); - - for (j = 0; j < 8; j++) - { - GpeNumber = AcpiGbl_GpeRegisters[RegisterIndex].GpeBase + j; - AcpiGbl_GpeValid[GpeNumber] = (UINT8) RegisterIndex; - } - - /* - * Clear the status/enable registers. Note that status registers - * are cleared by writing a '1', while enable registers are cleared - * by writing a '0'. - */ - AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, 0x00); - AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, 0xFF); - - RegisterIndex++; - } - - /* GPE Block 1 */ - - for (i = 0; i < Gpe1RegisterCount; i++) - { - AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr = - (UINT16) (ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) + i); - - AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr = - (UINT16) (ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) + i + Gpe1RegisterCount); - - AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = - (UINT8) (AcpiGbl_FADT->Gpe1Base + MUL_8 (i)); - - for (j = 0; j < 8; j++) - { - GpeNumber = AcpiGbl_GpeRegisters[RegisterIndex].GpeBase + j; - AcpiGbl_GpeValid[GpeNumber] = (UINT8) RegisterIndex; - } - - /* - * Clear the status/enable registers. Note that status registers - * are cleared by writing a '1', while enable registers are cleared - * by writing a '0'. - */ - AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, 0x00); - AcpiOsOut8 (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, 0xFF); - - RegisterIndex++; - } - - DEBUG_PRINT (ACPI_INFO, - ("GPE registers: %X@%p (Blk0) %X@%p (Blk1)\n", - Gpe0RegisterCount, AcpiGbl_FADT->XGpe0Blk.Address, Gpe1RegisterCount, - AcpiGbl_FADT->XGpe1Blk.Address)); - - return_ACPI_STATUS (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvSaveMethodInfo - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a - * control method under the _GPE portion of the namespace. - * Extract the name and GPE type from the object, saving this - * information for quick lookup during GPE dispatch - * - * The name of each GPE control method is of the form: - * "_Lnn" or "_Enn" - * Where: - * L - means that the GPE is level triggered - * E - means that the GPE is edge triggered - * nn - is the GPE number - * - ******************************************************************************/ - -static ACPI_STATUS -AcpiEvSaveMethodInfo ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *ObjDesc, - void **ReturnValue) -{ - UINT32 GpeNumber; - NATIVE_CHAR Name[ACPI_NAME_SIZE + 1]; - UINT8 Type; - - - /* Extract the name from the object and convert to a string */ - - MOVE_UNALIGNED32_TO_32 (Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name); - Name[ACPI_NAME_SIZE] = 0; - - /* - * Edge/Level determination is based on the 2nd INT8 of the method name - */ - if (Name[1] == 'L') - { - Type = ACPI_EVENT_LEVEL_TRIGGERED; - } - else if (Name[1] == 'E') - { - Type = ACPI_EVENT_EDGE_TRIGGERED; - } - else - { - /* Unknown method type, just ignore it! */ - - DEBUG_PRINT (ACPI_ERROR, - ("EvSaveMethodInfo: Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n", - Name)); - return (AE_OK); - } - - /* Convert the last two characters of the name to the Gpe Number */ - - GpeNumber = STRTOUL (&Name[2], NULL, 16); - if (GpeNumber == ACPI_UINT32_MAX) - { - /* Conversion failed; invalid method, just ignore it */ - - DEBUG_PRINT (ACPI_ERROR, - ("EvSaveMethodInfo: Could not extract GPE number from name: %s (name not of form _Lnn or _Enn)\n", - Name)); - return (AE_OK); - } - - /* Ensure that we have a valid GPE number */ - - if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) - { - /* Not valid, all we can do here is ignore it */ - - return (AE_OK); - } - - /* - * Now we can add this information to the GpeInfo block - * for use during dispatch of this GPE. - */ - - AcpiGbl_GpeInfo [GpeNumber].Type = Type; - AcpiGbl_GpeInfo [GpeNumber].MethodHandle = ObjHandle; - - - /* - * Enable the GPE (SCIs should be disabled at this point) - */ - - AcpiHwEnableGpe (GpeNumber); - - DEBUG_PRINT (ACPI_INFO, - ("EvSaveMethodInfo: Registered GPE method %s as GPE number %X\n", - Name, GpeNumber)); - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvInitGpeControlMethods - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Obtain the control methods associated with the GPEs. - * - * NOTE: Must be called AFTER namespace initialization! - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvInitGpeControlMethods (void) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvInitGpeControlMethods"); - - - /* Get a permanent handle to the _GPE object */ - - Status = AcpiGetHandle (NULL, "\\_GPE", &AcpiGbl_GpeObjHandle); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* Traverse the namespace under \_GPE to find all methods there */ - - Status = AcpiWalkNamespace (ACPI_TYPE_METHOD, AcpiGbl_GpeObjHandle, - ACPI_UINT32_MAX, AcpiEvSaveMethodInfo, - NULL, NULL); - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvGpeDetect - * - * PARAMETERS: None - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Detect if any GP events have occurred - * - ******************************************************************************/ - -UINT32 -AcpiEvGpeDetect (void) -{ - UINT32 IntStatus = INTERRUPT_NOT_HANDLED; - UINT32 i; - UINT32 j; - UINT8 EnabledStatusByte; - UINT8 BitMask; - - - /* - * Read all of the 8-bit GPE status and enable registers - * in both of the register blocks, saving all of it. - * Find all currently active GP events. - */ - - for (i = 0; i < AcpiGbl_GpeRegisterCount; i++) - { - AcpiGbl_GpeRegisters[i].Status = - AcpiOsIn8 (AcpiGbl_GpeRegisters[i].StatusAddr); - - AcpiGbl_GpeRegisters[i].Enable = - AcpiOsIn8 (AcpiGbl_GpeRegisters[i].EnableAddr); - - DEBUG_PRINT (TRACE_INTERRUPTS, - ("GPE block at %x - Enable: %08x\tStatus: %08x\n", - AcpiGbl_GpeRegisters[i].EnableAddr, AcpiGbl_GpeRegisters[i].Status, AcpiGbl_GpeRegisters[i].Enable)); - - /* First check if there is anything active at all in this register */ - - EnabledStatusByte = (UINT8) (AcpiGbl_GpeRegisters[i].Status & - AcpiGbl_GpeRegisters[i].Enable); - - if (!EnabledStatusByte) - { - /* No active GPEs in this register, move on */ - - continue; - } - - /* Now look at the individual GPEs in this byte register */ - - for (j = 0, BitMask = 1; j < 8; j++, BitMask <<= 1) - { - /* Examine one GPE bit */ - - if (EnabledStatusByte & BitMask) - { - /* - * Found an active GPE. Dispatch the event to a handler - * or method. - */ - IntStatus |= - AcpiEvGpeDispatch (AcpiGbl_GpeRegisters[i].GpeBase + j); - } - } - } - - return (IntStatus); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvAsynchExecuteGpeMethod - * - * PARAMETERS: GpeNumber - The 0-based Gpe number - * - * RETURN: None - * - * DESCRIPTION: Perform the actual execution of a GPE control method. This - * function is called from an invocation of AcpiOsQueueForExecution - * (and therefore does NOT execute at interrupt level) so that - * the control method itself is not executed in the context of - * the SCI interrupt handler. - * - ******************************************************************************/ - -static void -AcpiEvAsynchExecuteGpeMethod ( - void *Context) -{ - UINT32 GpeNumber = (UINT32) Context; - ACPI_GPE_LEVEL_INFO GpeInfo; - - - FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); - - /* - * Take a snapshot of the GPE info for this level - */ - AcpiCmAcquireMutex (ACPI_MTX_EVENTS); - GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; - AcpiCmReleaseMutex (ACPI_MTX_EVENTS); - - /* - * Method Handler (_Lxx, _Exx): - * ---------------------------- - * Evaluate the _Lxx/_Exx control method that corresponds to this GPE. - */ - if (GpeInfo.MethodHandle) - { - AcpiNsEvaluateByHandle (GpeInfo.MethodHandle, NULL, NULL); - } - - /* - * Level-Triggered? - * ---------------- - * If level-triggered we clear the GPE status bit after handling the event. - */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) - { - AcpiHwClearGpe (GpeNumber); - } - - /* - * Enable the GPE. - */ - AcpiHwEnableGpe (GpeNumber); - - return_VOID; -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvGpeDispatch - * - * PARAMETERS: GpeNumber - The 0-based Gpe number - * - * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED - * - * DESCRIPTION: Handle and dispatch a General Purpose AcpiEvent. - * Clears the status bit for the requested event. - * - * TBD: [Investigate] is this still valid or necessary: - * The Gpe handler differs from the fixed events in that it clears the enable - * bit rather than the status bit to clear the interrupt. This allows - * software outside of interrupt context to determine what caused the SCI and - * dispatch the correct AML. - * - ******************************************************************************/ - -UINT32 -AcpiEvGpeDispatch ( - UINT32 GpeNumber) -{ - ACPI_GPE_LEVEL_INFO GpeInfo; - - FUNCTION_TRACE ("EvGpeDispatch"); - - /*DEBUG_INCREMENT_EVENT_COUNT (EVENT_GENERAL);*/ - - /* - * Valid GPE number? - */ - if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) - { - DEBUG_PRINT (ACPI_ERROR, ("Invalid GPE bit [%X].\n", GpeNumber)); - return_VALUE (INTERRUPT_NOT_HANDLED); - } - - /* - * Disable the GPE. - */ - AcpiHwDisableGpe (GpeNumber); - - GpeInfo = AcpiGbl_GpeInfo [GpeNumber]; - - /* - * Edge-Triggered? - * --------------- - * If edge-triggered, clear the GPE status bit now. Note that - * level-triggered events are cleared after the GPE is serviced. - */ - if (GpeInfo.Type & ACPI_EVENT_EDGE_TRIGGERED) - { - AcpiHwClearGpe (GpeNumber); - } - /* - * Function Handler (e.g. EC)? - */ - if (GpeInfo.Handler) - { - /* Invoke function handler (at interrupt level). */ - GpeInfo.Handler (GpeInfo.Context); - - /* Level-Triggered? */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) - { - AcpiHwClearGpe (GpeNumber); - } - - /* Enable GPE */ - AcpiHwEnableGpe (GpeNumber); - } - /* - * Method Handler (e.g. _Exx/_Lxx)? - */ - else if (GpeInfo.MethodHandle) - { - if (ACPI_FAILURE(AcpiOsQueueForExecution (OSD_PRIORITY_GPE, - AcpiEvAsynchExecuteGpeMethod, (void*)(NATIVE_UINT)GpeNumber))) - { - /* - * Shoudn't occur, but if it does report an error. Note that - * the GPE will remain disabled until the ACPI Core Subsystem - * is restarted, or the handler is removed/reinstalled. - */ - REPORT_ERROR (("AcpiEvGpeDispatch: Unable to queue handler for GPE bit [%X]\n", GpeNumber)); - } - } - /* - * No Handler? Report an error and leave the GPE disabled. - */ - else - { - REPORT_ERROR (("AcpiEvGpeDispatch: No installed handler for GPE [%X]\n", GpeNumber)); - - /* Level-Triggered? */ - if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) - { - AcpiHwClearGpe (GpeNumber); - } - } - - return_VALUE (INTERRUPT_HANDLED); -} diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evmisc.c b/sys/contrib/dev/acpica/Subsystem/Events/evmisc.c deleted file mode 100644 index 516774e2361aa..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evmisc.c +++ /dev/null @@ -1,486 +0,0 @@ -/****************************************************************************** - * - * Module Name: evmisc - ACPI device notification handler dispatch - * and ACPI Global Lock support - * $Revision: 22 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "achware.h" - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evmisc") - - -/************************************************************************** - * - * FUNCTION: AcpiEvNotifyDispatch - * - * PARAMETERS: - * - * RETURN: None. - * - * DESCRIPTION: Dispatch a device notification event to a previously - * installed handler. - * - *************************************************************************/ - -void -AcpiEvNotifyDispatch ( - ACPI_HANDLE Device, - UINT32 NotifyValue) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *HandlerObj; - NOTIFY_HANDLER Handler; - - - /* - * For value 1 (Ejection Request), some device method may need to be run. - * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. - * For value 0x80 (Status Change) on the power button or sleep button, - * initiate soft-off or sleep operation? - */ - - - DEBUG_PRINT (ACPI_INFO, - ("Dispatching Notify(%X) on device %p\n", NotifyValue, Device)); - - switch (NotifyValue) - { - case 0: - DEBUG_PRINT (ACPI_INFO, ("Notify value: Re-enumerate Devices\n")); - break; - - case 1: - DEBUG_PRINT (ACPI_INFO, ("Notify value: Ejection Request\n")); - break; - - case 2: - DEBUG_PRINT (ACPI_INFO, ("Notify value: Device Wake\n")); - break; - - case 0x80: - DEBUG_PRINT (ACPI_INFO, ("Notify value: Status Change\n")); - break; - - default: - DEBUG_PRINT (ACPI_INFO, ("Unknown Notify Value: %lx \n", NotifyValue)); - break; - } - - - /* - * Invoke a global notify handler if installed. - * This is done _before_ we invoke the per-device handler attached to the device. - */ - - if (NotifyValue <= MAX_SYS_NOTIFY) - { - /* Global system notification handler */ - - if (AcpiGbl_SysNotify.Handler) - { - AcpiGbl_SysNotify.Handler (Device, NotifyValue, - AcpiGbl_SysNotify.Context); - } - } - - else - { - /* Global driver notification handler */ - - if (AcpiGbl_DrvNotify.Handler) - { - AcpiGbl_DrvNotify.Handler (Device, NotifyValue, - AcpiGbl_DrvNotify.Context); - } - } - - - /* - * Get the notify object which must be attached to the device Node - */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Device); - if (!ObjDesc) - { - /* There can be no notify handler for this device */ - - DEBUG_PRINT (ACPI_INFO, - ("No notify handler for device %p \n", Device)); - return; - } - - - /* We have the notify object, Get the right handler */ - - if (NotifyValue <= MAX_SYS_NOTIFY) - { - HandlerObj = ObjDesc->Device.SysHandler; - } - else - { - HandlerObj = ObjDesc->Device.DrvHandler; - } - - /* Validate the handler */ - - if (!HandlerObj) - { - /* There is no notify handler for this device */ - - DEBUG_PRINT (ACPI_INFO, - ("No notify handler for device %p \n", Device)); - return; - } - - /* There is a handler, invoke it */ - - Handler = HandlerObj->NotifyHandler.Handler; - Handler (Device, NotifyValue, HandlerObj->NotifyHandler.Context); - -} - - -/*************************************************************************** - * - * FUNCTION: AcpiEvGlobalLockThread - * - * RETURN: None - * - * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the - * Global Lock. Simply signal all threads that are waiting - * for the lock. - * - **************************************************************************/ - -static void -AcpiEvGlobalLockThread ( - void *Context) -{ - - /* Signal threads that are waiting for the lock */ - - if (AcpiGbl_GlobalLockThreadCount) - { - /* Send sufficient units to the semaphore */ - - AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, - AcpiGbl_GlobalLockThreadCount); - } -} - - -/*************************************************************************** - * - * FUNCTION: AcpiEvGlobalLockHandler - * - * RETURN: Status - * - * DESCRIPTION: Invoked directly from the SCI handler when a global lock - * release interrupt occurs. Grab the global lock and queue - * the global lock thread for execution - * - **************************************************************************/ - -static UINT32 -AcpiEvGlobalLockHandler ( - void *Context) -{ - BOOLEAN Acquired = FALSE; - void *GlobalLock; - - - /* - * Attempt to get the lock - * If we don't get it now, it will be marked pending and we will - * take another interrupt when it becomes free. - */ - - GlobalLock = AcpiGbl_FACS->GlobalLock; - ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); - if (Acquired) - { - /* Got the lock, now wake all threads waiting for it */ - - AcpiGbl_GlobalLockAcquired = TRUE; - - /* Run the Global Lock thread which will signal all waiting threads */ - - AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, AcpiEvGlobalLockThread, - Context); - } - - return (INTERRUPT_HANDLED); -} - - -/*************************************************************************** - * - * FUNCTION: AcpiEvInitGlobalLockHandler - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for the global lock release event - * - **************************************************************************/ - -ACPI_STATUS -AcpiEvInitGlobalLockHandler (void) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvInitGlobalLockHandler"); - - - Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, - AcpiEvGlobalLockHandler, NULL); - - return_ACPI_STATUS (Status); -} - - -/*************************************************************************** - * - * FUNCTION: AcpiEvAcquireGlobalLock - * - * RETURN: Status - * - * DESCRIPTION: Attempt to gain ownership of the Global Lock. - * - **************************************************************************/ - -ACPI_STATUS -AcpiEvAcquireGlobalLock(void) -{ - ACPI_STATUS Status = AE_OK; - BOOLEAN Acquired = FALSE; - void *GlobalLock; - - - FUNCTION_TRACE ("EvAcquireGlobalLock"); - - - /* One more thread wants the global lock */ - - AcpiGbl_GlobalLockThreadCount++; - - - /* If we (OS side) have the hardware lock already, we are done */ - - if (AcpiGbl_GlobalLockAcquired) - { - return_ACPI_STATUS (AE_OK); - } - - /* Only if the FACS is valid */ - - if (!AcpiGbl_FACS) - { - return_ACPI_STATUS (AE_OK); - } - - - /* We must acquire the actual hardware lock */ - - GlobalLock = AcpiGbl_FACS->GlobalLock; - ACPI_ACQUIRE_GLOBAL_LOCK (GlobalLock, Acquired); - if (Acquired) - { - /* We got the lock */ - - DEBUG_PRINT (ACPI_INFO, ("Acquired the HW Global Lock\n")); - - AcpiGbl_GlobalLockAcquired = TRUE; - - return_ACPI_STATUS (AE_OK); - } - - - /* - * Did not get the lock. The pending bit was set above, and we must now - * wait until we get the global lock released interrupt. - */ - - DEBUG_PRINT (ACPI_INFO, ("Waiting for the HW Global Lock\n")); - - /* - * Acquire the global lock semaphore first. - * Since this wait will block, we must release the interpreter - */ - - Status = AcpiAmlSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, - ACPI_UINT32_MAX); - - return_ACPI_STATUS (Status); -} - - -/*************************************************************************** - * - * FUNCTION: AcpiEvReleaseGlobalLock - * - * DESCRIPTION: Releases ownership of the Global Lock. - * - **************************************************************************/ - -void -AcpiEvReleaseGlobalLock (void) -{ - BOOLEAN Pending = FALSE; - void *GlobalLock; - - - FUNCTION_TRACE ("EvReleaseGlobalLock"); - - if (!AcpiGbl_GlobalLockThreadCount) - { - REPORT_WARNING(("Releasing a non-acquired Global Lock\n")); - return_VOID; - } - - /* One fewer thread has the global lock */ - - AcpiGbl_GlobalLockThreadCount--; - - /* Have all threads released the lock? */ - - if (!AcpiGbl_GlobalLockThreadCount) - { - /* - * No more threads holding lock, we can do the actual hardware - * release - */ - - GlobalLock = AcpiGbl_FACS->GlobalLock; - ACPI_RELEASE_GLOBAL_LOCK (GlobalLock, Pending); - AcpiGbl_GlobalLockAcquired = FALSE; - - /* - * If the pending bit was set, we must write GBL_RLS to the control - * register - */ - if (Pending) - { - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, - GBL_RLS, 1); - } - } - - return_VOID; -} diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evregion.c b/sys/contrib/dev/acpica/Subsystem/Events/evregion.c deleted file mode 100644 index e9ebad9894a6f..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evregion.c +++ /dev/null @@ -1,778 +0,0 @@ -/****************************************************************************** - * - * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * $Revision: 96 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __EVREGION_C__ - -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "amlcode.h" - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evregion") - - -/************************************************************************** - * - * FUNCTION: AcpiEvInstallDefaultAddressSpaceHandlers - * - * PARAMETERS: - * - * RETURN: Status - * - * DESCRIPTION: Installs the core subsystem address space handlers. - * - *************************************************************************/ - -ACPI_STATUS -AcpiEvInstallDefaultAddressSpaceHandlers ( - void) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvInstallDefaultAddressSpaceHandlers"); - - /* - * All address spaces (PCI Config, EC, SMBus) are scope dependent - * and registration must occur for a specific device. In the case - * system memory and IO address spaces there is currently no device - * associated with the address space. For these we use the root. - * We install the default PCI config space handler at the root so - * that this space is immediately available even though the we have - * not enumerated all the PCI Root Buses yet. This is to conform - * to the ACPI specification which states that the PCI config - * space must be always available -- even though we are nowhere - * near ready to find the PCI root buses at this point. - * - * NOTE: We ignore AE_EXIST because this means that a handler has - * already been installed (via AcpiInstallAddressSpaceHandler) - */ - - Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, - ADDRESS_SPACE_SYSTEM_MEMORY, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if ((ACPI_FAILURE (Status)) && - (Status != AE_EXIST)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, - ADDRESS_SPACE_SYSTEM_IO, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if ((ACPI_FAILURE (Status)) && - (Status != AE_EXIST)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, - ADDRESS_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); - if ((ACPI_FAILURE (Status)) && - (Status != AE_EXIST)) - { - return_ACPI_STATUS (Status); - } - - - return_ACPI_STATUS (AE_OK); -} - - -/* TBD: [Restructure] Move elsewhere */ - -/************************************************************************** - * - * FUNCTION: AcpiEvExecuteRegMethod - * - * PARAMETERS: RegionObj - Object structure - * Function - On (1) or Off (0) - * - * RETURN: Status - * - * DESCRIPTION: Execute _REG method for a region - * - *************************************************************************/ - -static ACPI_STATUS -AcpiEvExecuteRegMethod ( - ACPI_OPERAND_OBJECT *RegionObj, - UINT32 Function) -{ - ACPI_OPERAND_OBJECT *Params[3]; - ACPI_OPERAND_OBJECT SpaceIdDesc; - ACPI_OPERAND_OBJECT FunctionDesc; - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvExecuteRegMethod"); - - - if (RegionObj->Region.Extra->Extra.Method_REG == NULL) - { - return_ACPI_STATUS (AE_OK); - } - - /* - * _REG method has two arguments - * Arg0: Integer: Operation region space ID - * Same value as RegionObj->Region.SpaceId - * Arg1: Integer: connection status - * 1 for connecting the handler, - * 0 for disconnecting the handler - * Passed as a parameter - */ - - AcpiCmInitStaticObject (&SpaceIdDesc); - AcpiCmInitStaticObject (&FunctionDesc); - - /* - * Method requires two parameters. - */ - Params [0] = &SpaceIdDesc; - Params [1] = &FunctionDesc; - Params [2] = NULL; - - /* - * Set up the parameter objects - */ - SpaceIdDesc.Common.Type = ACPI_TYPE_INTEGER; - SpaceIdDesc.Integer.Value = RegionObj->Region.SpaceId; - - FunctionDesc.Common.Type = ACPI_TYPE_INTEGER; - FunctionDesc.Integer.Value = Function; - - /* - * Execute the method, no return value - */ - DEBUG_EXEC(AcpiCmDisplayInitPathname (RegionObj->Region.Extra->Extra.Method_REG, " [Method]")); - Status = AcpiNsEvaluateByHandle (RegionObj->Region.Extra->Extra.Method_REG, Params, NULL); - return_ACPI_STATUS (Status); -} - - -/************************************************************************** - * - * FUNCTION: AcpiEvAddressSpaceDispatch - * - * PARAMETERS: RegionObj - internal region object - * SpaceId - ID of the address space (0-255) - * Function - Read or Write operation - * Address - Where in the space to read or write - * BitWidth - Field width in bits (8, 16, or 32) - * Value - Pointer to in or out value - * - * RETURN: Status - * - * DESCRIPTION: Dispatch an address space or operation region access to - * a previously installed handler. - * - *************************************************************************/ - -ACPI_STATUS -AcpiEvAddressSpaceDispatch ( - ACPI_OPERAND_OBJECT *RegionObj, - UINT32 Function, - ACPI_PHYSICAL_ADDRESS Address, - UINT32 BitWidth, - UINT32 *Value) -{ - ACPI_STATUS Status; - ADDRESS_SPACE_HANDLER Handler; - ADDRESS_SPACE_SETUP RegionSetup; - ACPI_OPERAND_OBJECT *HandlerDesc; - void *RegionContext = NULL; - - - FUNCTION_TRACE ("EvAddressSpaceDispatch"); - - - /* - * Check for an installed handler - */ - HandlerDesc = RegionObj->Region.AddrHandler; - - if (!HandlerDesc) - { - DEBUG_PRINT (TRACE_OPREGION, - ("Dispatch address access region %p, no handler\n", RegionObj)); - return_ACPI_STATUS(AE_NOT_EXIST); - } - - /* - * It may be the case that the region has never been initialized - * Some types of regions require special init code - */ - if (!(RegionObj->Region.Flags & AOPOBJ_INITIALIZED)) - { - /* - * This region has not been initialized yet, do it - */ - RegionSetup = HandlerDesc->AddrHandler.Setup; - if (!RegionSetup) - { - /* - * Bad news, no init routine and not init'd - */ - DEBUG_PRINT (ACPI_ERROR, - ("EvAddressSpaceDispatch: No init routine for region %p\n", - RegionObj)); - return_ACPI_STATUS (AE_UNKNOWN_STATUS); - } - - /* - * We must exit the interpreter because the region setup will potentially - * execute control methods - */ - AcpiAmlExitInterpreter (); - - Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, - HandlerDesc->AddrHandler.Context, - &RegionContext); - - /* Re-enter the interpreter */ - - AcpiAmlEnterInterpreter (); - - /* - * Init routine may fail - */ - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("EvAddressSpaceDispatch: %s from region init, SpaceID %X\n", - AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); - return_ACPI_STATUS(Status); - } - - RegionObj->Region.Flags |= AOPOBJ_INITIALIZED; - - /* - * Save the returned context for use in all accesses to - * this particular region. - */ - RegionObj->Region.Extra->Extra.RegionContext = RegionContext; - } - - /* - * We have everything we need, begin the process - */ - Handler = HandlerDesc->AddrHandler.Handler; - - DEBUG_PRINT ((TRACE_OPREGION | VERBOSE_INFO), - ("Addrhandler %p (%p), Address %p\n", - &RegionObj->Region.AddrHandler->AddrHandler, Handler, Address)); - - if (!(HandlerDesc->AddrHandler.Flags & ADDR_HANDLER_DEFAULT_INSTALLED)) - { - /* - * For handlers other than the default (supplied) handlers, we must - * exit the interpreter because the handler *might* block -- we don't - * know what it will do, so we can't hold the lock on the intepreter. - */ - AcpiAmlExitInterpreter(); - } - - /* - * Invoke the handler. - */ - Status = Handler (Function, Address, BitWidth, Value, - HandlerDesc->AddrHandler.Context, - RegionObj->Region.Extra->Extra.RegionContext); - - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("EvAddressSpaceDispatch: %s from handler, SpaceID %X\n", - AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); - } - - if (!(HandlerDesc->AddrHandler.Flags & ADDR_HANDLER_DEFAULT_INSTALLED)) - { - /* We just returned from a non-default handler, we must re-enter the - interpreter */ - - AcpiAmlEnterInterpreter (); - } - - return_ACPI_STATUS (Status); -} - -/****************************************************************************** - * - * FUNCTION: AcpiEvDisassociateRegionFromHandler - * - * PARAMETERS: RegionObj - Region Object - * AcpiNsIsLocked - Namespace Region Already Locked? - * - * RETURN: None - * - * DESCRIPTION: Break the association between the handler and the region - * this is a two way association. - * - ******************************************************************************/ - -void -AcpiEvDisassociateRegionFromHandler( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsIsLocked) -{ - ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT **LastObjPtr; - ADDRESS_SPACE_SETUP RegionSetup; - void *RegionContext; - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvDisassociateRegionFromHandler"); - - RegionContext = RegionObj->Region.Extra->Extra.RegionContext; - - /* - * Get the address handler from the region object - */ - - HandlerObj = RegionObj->Region.AddrHandler; - if (!HandlerObj) - { - /* - * This region has no handler, all done - */ - return_VOID; - } - - - /* - * Find this region in the handler's list - */ - - ObjDesc = HandlerObj->AddrHandler.RegionList; - LastObjPtr = &HandlerObj->AddrHandler.RegionList; - - while (ObjDesc) - { - /* - * See if this is the one - */ - if (ObjDesc == RegionObj) - { - DEBUG_PRINT (TRACE_OPREGION, - ("Removing Region %p from address handler %p\n", - RegionObj, HandlerObj)); - /* - * This is it, remove it from the handler's list - */ - *LastObjPtr = ObjDesc->Region.Next; - ObjDesc->Region.Next = NULL; /* Must clear field */ - - if (AcpiNsIsLocked) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - } - - /* - * Now stop region accesses by executing the _REG method - */ - AcpiEvExecuteRegMethod (RegionObj, 0); - - if (AcpiNsIsLocked) - { - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - } - - /* - * Call the setup handler with the deactivate notification - */ - RegionSetup = HandlerObj->AddrHandler.Setup; - Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, - HandlerObj->AddrHandler.Context, - &RegionContext); - - /* - * Init routine may fail, Just ignore errors - */ - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, - ("EvDisassociateRegionFromHandler: %s from region init, SpaceID %X\n", - AcpiCmFormatException (Status), RegionObj->Region.SpaceId)); - } - - RegionObj->Region.Flags &= ~(AOPOBJ_INITIALIZED); - - /* - * Remove handler reference in the region - * - * NOTE: this doesn't mean that the region goes away - * The region is just inaccessible as indicated to - * the _REG method - * - * If the region is on the handler's list - * this better be the region's handler - */ - ACPI_ASSERT (RegionObj->Region.AddrHandler == HandlerObj); - - RegionObj->Region.AddrHandler = NULL; - - return_VOID; - - } /* found the right handler */ - - /* - * Move through the linked list of handlers - */ - LastObjPtr = &ObjDesc->Region.Next; - ObjDesc = ObjDesc->Region.Next; - } - - /* - * If we get here, the region was not in the handler's region list - */ - DEBUG_PRINT (TRACE_OPREGION, - ("Cannot remove region %p from address handler %p\n", - RegionObj, HandlerObj)); - - return_VOID; -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvAssociateRegionAndHandler - * - * PARAMETERS: HandlerObj - Handler Object - * RegionObj - Region Object - * AcpiNsIsLocked - Namespace Region Already Locked? - * - * RETURN: None - * - * DESCRIPTION: Create the association between the handler and the region - * this is a two way association. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvAssociateRegionAndHandler ( - ACPI_OPERAND_OBJECT *HandlerObj, - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsIsLocked) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("EvAssociateRegionAndHandler"); - - - DEBUG_PRINT (TRACE_OPREGION, ("Adding Region %p to address handler %p\n", - RegionObj, HandlerObj)); - - ACPI_ASSERT (RegionObj->Region.SpaceId == HandlerObj->AddrHandler.SpaceId); - ACPI_ASSERT (RegionObj->Region.AddrHandler == 0); - - /* - * Link this region to the front of the handler's list - */ - - RegionObj->Region.Next = HandlerObj->AddrHandler.RegionList; - HandlerObj->AddrHandler.RegionList = RegionObj; - - /* - * set the region's handler - */ - -/* - HandlerObj->Common.ReferenceCount = - (UINT16) (HandlerObj->Common.ReferenceCount + - RegionObj->Common.ReferenceCount - 1); -*/ - RegionObj->Region.AddrHandler = HandlerObj; - - /* - * Last thing, tell all users that this region is usable - */ - if (AcpiNsIsLocked) - { - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - } - - Status = AcpiEvExecuteRegMethod (RegionObj, 1); - - if (AcpiNsIsLocked) - { - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - } - - return_ACPI_STATUS (Status); -} - - -/**************************************************************************** - * - * FUNCTION: AcpiEvAddrHandlerHelper - * - * PARAMETERS: Handle - Node to be dumped - * Level - Nesting level of the handle - * Context - Passed into AcpiNsWalkNamespace - * - * DESCRIPTION: This routine checks to see if the object is a Region if it - * is then the address handler is installed in it. - * - * If the Object is a Device, and the device has a handler of - * the same type then the search is terminated in that branch. - * - * This is because the existing handler is closer in proximity - * to any more regions than the one we are trying to install. - * - ***************************************************************************/ - -ACPI_STATUS -AcpiEvAddrHandlerHelper ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue) -{ - ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_OPERAND_OBJECT *TmpObj; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - - - HandlerObj = (ACPI_OPERAND_OBJECT *) Context; - - /* Parameter validation */ - - if (!HandlerObj) - { - return (AE_OK); - } - - /* Convert and validate the device handle */ - - Node = AcpiNsConvertHandleToEntry (ObjHandle); - if (!Node) - { - return (AE_BAD_PARAMETER); - } - - /* - * We only care about regions.and objects - * that can have address handlers - */ - - if ((Node->Type != ACPI_TYPE_DEVICE) && - (Node->Type != ACPI_TYPE_REGION) && - (Node != AcpiGbl_RootNode)) - { - return (AE_OK); - } - - /* Check for an existing internal object */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); - if (!ObjDesc) - { - /* - * The object DNE, we don't care about it - */ - return (AE_OK); - } - - /* - * Devices are handled different than regions - */ - if (IS_THIS_OBJECT_TYPE (ObjDesc, ACPI_TYPE_DEVICE)) - { - /* - * See if this guy has any handlers - */ - TmpObj = ObjDesc->Device.AddrHandler; - while (TmpObj) - { - /* - * Now let's see if it's for the same address space. - */ - if (TmpObj->AddrHandler.SpaceId == HandlerObj->AddrHandler.SpaceId) - { - /* - * It's for the same address space - */ - - DEBUG_PRINT (TRACE_OPREGION, - ("Found handler for region %s in device %p(%p) handler %p\n", - AcpiCmGetRegionName (HandlerObj->AddrHandler.SpaceId), ObjDesc, TmpObj, HandlerObj)); - - /* - * Since the object we found it on was a device, then it - * means that someone has already installed a handler for - * the branch of the namespace from this device on. Just - * bail out telling the walk routine to not traverse this - * branch. This preserves the scoping rule for handlers. - */ - return (AE_CTRL_DEPTH); - } - - /* - * Move through the linked list of handlers - */ - TmpObj = TmpObj->AddrHandler.Next; - } - - /* - * As long as the device didn't have a handler for this - * space we don't care about it. We just ignore it and - * proceed. - */ - return (AE_OK); - } - - /* - * Only here if it was a region - */ - ACPI_ASSERT (ObjDesc->Common.Type == ACPI_TYPE_REGION); - - if (ObjDesc->Region.SpaceId != HandlerObj->AddrHandler.SpaceId) - { - /* - * This region is for a different address space - * ignore it - */ - return (AE_OK); - } - - /* - * Now we have a region and it is for the handler's address - * space type. - * - * First disconnect region for any previous handler (if any) - */ - AcpiEvDisassociateRegionFromHandler (ObjDesc, FALSE); - - /* - * Then connect the region to the new handler - */ - Status = AcpiEvAssociateRegionAndHandler (HandlerObj, ObjDesc, FALSE); - - return (Status); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c b/sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c deleted file mode 100644 index f2ed119770e04..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evrgnini.c +++ /dev/null @@ -1,557 +0,0 @@ -/****************************************************************************** - * - * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init - * $Revision: 33 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __EVRGNINI_C__ - -#include "acpi.h" -#include "acevents.h" -#include "acnamesp.h" -#include "acinterp.h" -#include "amlcode.h" - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evrgnini") - - -/***************************************************************************** - * - * FUNCTION: AcpiEvSystemMemoryRegionSetup - * - * PARAMETERS: RegionObj - region we are interested in - * Function - start or stop - * HandlerContext - Address space handler context - * RegionContext - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling, a nop for now - * - ****************************************************************************/ - -ACPI_STATUS -AcpiEvSystemMemoryRegionSetup ( - ACPI_HANDLE Handle, - UINT32 Function, - void *HandlerContext, - void **RegionContext) -{ - FUNCTION_TRACE ("EvSystemMemoryRegionSetup"); - - - if (Function == ACPI_REGION_DEACTIVATE) - { - if (*RegionContext) - { - AcpiCmFree (*RegionContext); - *RegionContext = NULL; - } - return_ACPI_STATUS (AE_OK); - } - - - /* Activate. Create a new context */ - - *RegionContext = AcpiCmCallocate (sizeof (MEM_HANDLER_CONTEXT)); - if (!(*RegionContext)) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - return_ACPI_STATUS (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiEvIoSpaceRegionSetup - * - * PARAMETERS: RegionObj - region we are interested in - * Function - start or stop - * HandlerContext - Address space handler context - * RegionContext - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling - * - ****************************************************************************/ - -ACPI_STATUS -AcpiEvIoSpaceRegionSetup ( - ACPI_HANDLE Handle, - UINT32 Function, - void *HandlerContext, - void **RegionContext) -{ - FUNCTION_TRACE ("EvIoSpaceRegionSetup"); - - if (Function == ACPI_REGION_DEACTIVATE) - { - *RegionContext = NULL; - } - else - { - *RegionContext = HandlerContext; - } - - return_ACPI_STATUS (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiEvPciConfigRegionSetup - * - * PARAMETERS: RegionObj - region we are interested in - * Function - start or stop - * HandlerContext - Address space handler context - * RegionContext - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling - * - * MUTEX: Assumes namespace is not locked - * - ****************************************************************************/ - -ACPI_STATUS -AcpiEvPciConfigRegionSetup ( - ACPI_HANDLE Handle, - UINT32 Function, - void *HandlerContext, - void **RegionContext) -{ - ACPI_STATUS Status = AE_OK; - ACPI_INTEGER Temp; - PCI_HANDLER_CONTEXT *PciContext = *RegionContext; - ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; - DEVICE_ID ObjectHID; - - FUNCTION_TRACE ("EvPciConfigRegionSetup"); - - HandlerObj = RegionObj->Region.AddrHandler; - - if (!HandlerObj) - { - /* - * No installed handler. This shouldn't happen because the dispatch - * routine checks before we get here, but we check again just in case. - */ - DEBUG_PRINT (TRACE_OPREGION, - ("Attempting to init a region %X, with no handler\n", RegionObj)); - return_ACPI_STATUS(AE_NOT_EXIST); - } - - if (Function == ACPI_REGION_DEACTIVATE) - { - if (PciContext) - { - AcpiCmFree (PciContext); - *RegionContext = NULL; - } - - return_ACPI_STATUS (Status); - } - - - /* Create a new context */ - - PciContext = AcpiCmCallocate (sizeof(PCI_HANDLER_CONTEXT)); - if (!PciContext) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* - * For PCI Config space access, we have to pass the segment, bus, - * device and function numbers. This routine must acquire those. - */ - - /* - * First get device and function numbers from the _ADR object - * in the parent's scope. - */ - ACPI_ASSERT(RegionObj->Region.Node); - - Node = AcpiNsGetParentObject (RegionObj->Region.Node); - - - /* AcpiEvaluate the _ADR object */ - - Status = AcpiCmEvaluateNumericObject (METHOD_NAME__ADR, Node, &Temp); - /* - * The default is zero, since the allocation above zeroed the data, just - * do nothing on failures. - */ - if (ACPI_SUCCESS (Status)) - { - /* - * Got it.. - */ - PciContext->DevFunc = (UINT32) Temp; - } - - /* - * 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 AddrHandler.Node is still pointing to the root, we need - * to scan upward for a PCI Root bridge and re-associate the OpRegion - * handlers with that device. - */ - if (HandlerObj->AddrHandler.Node == AcpiGbl_RootNode) - { - /* - * Node is currently the parent object - */ - while (Node != AcpiGbl_RootNode) - { - Status = AcpiCmExecute_HID(Node, &ObjectHID); - - if (ACPI_SUCCESS (Status)) - { - if (!(STRNCMP(ObjectHID.Buffer, PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING)))) - { - AcpiInstallAddressSpaceHandler(Node, - ADDRESS_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, NULL, NULL); - - break; - } - } - - Node = AcpiNsGetParentObject(Node); - } - } - else - { - Node = HandlerObj->AddrHandler.Node; - } - - Status = AcpiCmEvaluateNumericObject (METHOD_NAME__SEG, Node, &Temp); - if (ACPI_SUCCESS (Status)) - { - /* - * Got it.. - */ - PciContext->Seg = (UINT32) Temp; - } - - Status = AcpiCmEvaluateNumericObject (METHOD_NAME__BBN, Node, &Temp); - if (ACPI_SUCCESS (Status)) - { - /* - * Got it.. - */ - PciContext->Bus = (UINT32) Temp; - } - - *RegionContext = PciContext; - - return_ACPI_STATUS (AE_OK); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiEvDefaultRegionSetup - * - * PARAMETERS: RegionObj - region we are interested in - * Function - start or stop - * HandlerContext - Address space handler context - * RegionContext - Region specific context - * - * RETURN: Status - * - * DESCRIPTION: Do any prep work for region handling - * - ****************************************************************************/ - -ACPI_STATUS -AcpiEvDefaultRegionSetup ( - ACPI_HANDLE Handle, - UINT32 Function, - void *HandlerContext, - void **RegionContext) -{ - FUNCTION_TRACE ("EvDefaultRegionSetup"); - - if (Function == ACPI_REGION_DEACTIVATE) - { - *RegionContext = NULL; - } - else - { - *RegionContext = HandlerContext; - } - - return_ACPI_STATUS (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvInitializeRegion - * - * PARAMETERS: RegionObj - Region we are initializing - * - * 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 intialization. For - * example, PCI regions must have an _ADR object that contains - * a PCI address in the scope of the defintion. This address is - * required to perform an access to PCI config space. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvInitializeRegion ( - ACPI_OPERAND_OBJECT *RegionObj, - BOOLEAN AcpiNsLocked) -{ - ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_ADDRESS_SPACE_TYPE SpaceId; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *MethodNode; - ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; - - - FUNCTION_TRACE_U32 ("EvInitializeRegion", AcpiNsLocked); - - - if (!RegionObj) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - ACPI_ASSERT(RegionObj->Region.Node); - - Node = AcpiNsGetParentObject (RegionObj->Region.Node); - SpaceId = RegionObj->Region.SpaceId; - - RegionObj->Region.AddrHandler = NULL; - RegionObj->Region.Extra->Extra.Method_REG = NULL; - RegionObj->Region.Flags &= ~(AOPOBJ_INITIALIZED); - - /* - * Find any "_REG" associated with this region definition - */ - Status = AcpiNsSearchNode (*RegNamePtr, Node, - ACPI_TYPE_METHOD, &MethodNode); - if (ACPI_SUCCESS (Status)) - { - /* - * 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 - */ - RegionObj->Region.Extra->Extra.Method_REG = MethodNode; - } - - /* - * The following loop depends upon the root Node having no parent - * ie: AcpiGbl_RootNode->ParentEntry being set to NULL - */ - while (Node) - { - /* - * Check to see if a handler exists - */ - HandlerObj = NULL; - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); - if (ObjDesc) - { - /* - * can only be a handler if the object exists - */ - switch (Node->Type) - { - case ACPI_TYPE_DEVICE: - - HandlerObj = ObjDesc->Device.AddrHandler; - break; - - case ACPI_TYPE_PROCESSOR: - - HandlerObj = ObjDesc->Processor.AddrHandler; - break; - - case ACPI_TYPE_THERMAL: - - HandlerObj = ObjDesc->ThermalZone.AddrHandler; - break; - } - - while (HandlerObj) - { - /* - * This guy has at least one address handler - * see if it has the type we want - */ - if (HandlerObj->AddrHandler.SpaceId == SpaceId) - { - DEBUG_PRINT (TRACE_OPREGION, - ("Found handler %p for region %p in obj %p\n", - HandlerObj, RegionObj, ObjDesc)); - - /* - * Found it! Now update the region and the handler - */ - AcpiEvAssociateRegionAndHandler (HandlerObj, RegionObj, AcpiNsLocked); - return_ACPI_STATUS (AE_OK); - } - - HandlerObj = HandlerObj->AddrHandler.Next; - - } /* while handlerobj */ - } - - /* - * This one does not have the handler we need - * Pop up one level - */ - Node = AcpiNsGetParentObject (Node); - - } /* while Node != ROOT */ - - /* - * If we get here, there is no handler for this region - */ - DEBUG_PRINT (TRACE_OPREGION, - ("No handler for RegionType %s(%X) (RegionObj %p)\n", - AcpiCmGetRegionName (SpaceId), SpaceId, RegionObj)); - - return_ACPI_STATUS (AE_NOT_EXIST); -} - diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evsci.c b/sys/contrib/dev/acpica/Subsystem/Events/evsci.c deleted file mode 100644 index 130156cebe836..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evsci.c +++ /dev/null @@ -1,436 +0,0 @@ -/******************************************************************************* - * - * Module Name: evsci - System Control Interrupt configuration and - * legacy to ACPI mode state transition functions - * $Revision: 69 $ - * - ******************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#include "acpi.h" -#include "acnamesp.h" -#include "achware.h" -#include "acevents.h" - - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evsci") - - -/* - * Elements correspond to counts for TMR, NOT_USED, GBL, PWR_BTN, SLP_BTN, RTC, - * and GENERAL respectively. These counts are modified by the ACPI interrupt - * handler. - * - * TBD: [Investigate] Note that GENERAL should probably be split out into - * one element for each bit in the GPE registers - */ - - -/******************************************************************************* - * - * FUNCTION: AcpiEvSciHandler - * - * PARAMETERS: Context - Calling Context - * - * RETURN: Status code indicates whether interrupt was handled. - * - * DESCRIPTION: Interrupt handler that will figure out what function or - * control method to call to deal with a SCI. Installed - * using BU interrupt support. - * - ******************************************************************************/ - -static UINT32 -AcpiEvSciHandler (void *Context) -{ - UINT32 InterruptHandled = INTERRUPT_NOT_HANDLED; - - - FUNCTION_TRACE("EvSciHandler"); - - - /* - * Make sure that ACPI is enabled by checking SCI_EN. Note that we are - * required to treat the SCI interrupt as sharable, level, active low. - */ - if (!AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_DO_NOT_LOCK, SCI_EN)) - { - /* ACPI is not enabled; this interrupt cannot be for us */ - - return_VALUE (INTERRUPT_NOT_HANDLED); - } - - /* - * Fixed AcpiEvents: - * ------------- - * Check for and dispatch any Fixed AcpiEvents that have occurred - */ - InterruptHandled |= AcpiEvFixedEventDetect (); - - /* - * GPEs: - * ----- - * Check for and dispatch any GPEs that have occurred - */ - InterruptHandled |= AcpiEvGpeDetect (); - - return_VALUE (InterruptHandled); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvInstallSciHandler - * - * PARAMETERS: none - * - * RETURN: Status - * - * DESCRIPTION: Installs SCI handler. - * - ******************************************************************************/ - -UINT32 -AcpiEvInstallSciHandler (void) -{ - UINT32 Except = AE_OK; - - - FUNCTION_TRACE ("EvInstallSciHandler"); - - - Except = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT->SciInt, - AcpiEvSciHandler, - NULL); - - return_ACPI_STATUS (Except); -} - - -/****************************************************************************** - - * - * FUNCTION: AcpiEvRemoveSciHandler - * - * PARAMETERS: none - * - * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not - * installed to begin with - * - * DESCRIPTION: Restores original status of all fixed event enable bits and - * removes SCI handler. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEvRemoveSciHandler (void) -{ - FUNCTION_TRACE ("EvRemoveSciHandler"); - -#if 0 - /* TBD:[Investigate] Figure this out!! Disable all events first ??? */ - - if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (TMR_FIXED_EVENT)) - { - AcpiEventDisableEvent (TMR_FIXED_EVENT); - } - - if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (GBL_FIXED_EVENT)) - { - AcpiEventDisableEvent (GBL_FIXED_EVENT); - } - - if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (PWR_BTN_FIXED_EVENT)) - { - AcpiEventDisableEvent (PWR_BTN_FIXED_EVENT); - } - - if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (SLP_BTN_FIXED_EVENT)) - { - AcpiEventDisableEvent (SLP_BTN_FIXED_EVENT); - } - - if (OriginalFixedEnableBitStatus ^ 1 << AcpiEventIndex (RTC_FIXED_EVENT)) - { - AcpiEventDisableEvent (RTC_FIXED_EVENT); - } - - OriginalFixedEnableBitStatus = 0; - -#endif - - AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT->SciInt, - AcpiEvSciHandler); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiEvSciCount - * - * PARAMETERS: Event Event that generated an SCI. - * - * RETURN: Number of SCI's for requested event since last time - * SciOccured() was called for this event. - * - * DESCRIPTION: Checks to see if SCI has been generated from requested source - * since the last time this function was called. - * - ******************************************************************************/ - -#ifdef ACPI_DEBUG - -UINT32 -AcpiEvSciCount ( - UINT32 Event) -{ - UINT32 Count; - - FUNCTION_TRACE ("EvSciCount"); - - /* - * Elements correspond to counts for TMR, NOT_USED, GBL, - * PWR_BTN, SLP_BTN, RTC, and GENERAL respectively. - */ - - if (Event >= NUM_FIXED_EVENTS) - { - Count = (UINT32) -1; - } - else - { - Count = AcpiGbl_EventCount[Event]; - } - - return_VALUE (Count); -} - -#endif - - -/******************************************************************************* - * - * FUNCTION: AcpiEvRestoreAcpiState - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: Restore the original ACPI state of the machine - * - ******************************************************************************/ - -void -AcpiEvRestoreAcpiState (void) -{ - UINT32 Index; - - - FUNCTION_TRACE ("EvRestoreAcpiState"); - - - /* Restore the state of the chipset enable bits. */ - - if (AcpiGbl_RestoreAcpiChipset == TRUE) - { - /* Restore the fixed events */ - - if (AcpiHwRegisterRead (ACPI_MTX_LOCK, PM1_EN) != - AcpiGbl_Pm1EnableRegisterSave) - { - AcpiHwRegisterWrite (ACPI_MTX_LOCK, PM1_EN, - AcpiGbl_Pm1EnableRegisterSave); - } - - - /* Ensure that all status bits are clear */ - - AcpiHwClearAcpiStatus (); - - - /* Now restore the GPEs */ - - for (Index = 0; Index < DIV_2 (AcpiGbl_FADT->Gpe0BlkLen); Index++) - { - if (AcpiHwRegisterRead (ACPI_MTX_LOCK, GPE0_EN_BLOCK | Index) != - AcpiGbl_Gpe0EnableRegisterSave[Index]) - { - AcpiHwRegisterWrite (ACPI_MTX_LOCK, GPE0_EN_BLOCK | Index, - AcpiGbl_Gpe0EnableRegisterSave[Index]); - } - } - - /* GPE 1 present? */ - - if (AcpiGbl_FADT->Gpe1BlkLen) - { - for (Index = 0; Index < DIV_2 (AcpiGbl_FADT->Gpe1BlkLen); Index++) - { - if (AcpiHwRegisterRead (ACPI_MTX_LOCK, GPE1_EN_BLOCK | Index) != - AcpiGbl_Gpe1EnableRegisterSave[Index]) - { - AcpiHwRegisterWrite (ACPI_MTX_LOCK, GPE1_EN_BLOCK | Index, - AcpiGbl_Gpe1EnableRegisterSave[Index]); - } - } - } - - if (AcpiHwGetMode() != AcpiGbl_OriginalMode) - { - AcpiHwSetMode (AcpiGbl_OriginalMode); - } - } - - return_VOID; -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEvTerminate - * - * PARAMETERS: none - * - * RETURN: none - * - * DESCRIPTION: free memory allocated for table storage. - * - ******************************************************************************/ - -void -AcpiEvTerminate (void) -{ - - FUNCTION_TRACE ("EvTerminate"); - - - /* - * Free global tables, etc. - */ - - if (AcpiGbl_GpeRegisters) - { - AcpiCmFree (AcpiGbl_GpeRegisters); - } - - if (AcpiGbl_GpeInfo) - { - AcpiCmFree (AcpiGbl_GpeInfo); - } - - return_VOID; -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evxface.c b/sys/contrib/dev/acpica/Subsystem/Events/evxface.c deleted file mode 100644 index 89f9b8a2aa5bf..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evxface.c +++ /dev/null @@ -1,769 +0,0 @@ -/****************************************************************************** - * - * Module Name: evxface - External interfaces for ACPI events - * $Revision: 101 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial prton of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __EVXFACE_C__ - -#include "acpi.h" -#include "achware.h" -#include "acnamesp.h" -#include "acevents.h" -#include "amlcode.h" -#include "acinterp.h" - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evxface") - - -/****************************************************************************** - * - * FUNCTION: AcpiInstallFixedEventHandler - * - * PARAMETERS: Event - Event type to enable. - * Handler - Pointer to the handler function for the - * event - * Context - Value passed to the handler on each GPE - * - * RETURN: Status - * - * DESCRIPTION: Saves the pointer to the handler function and then enables the - * event. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiInstallFixedEventHandler ( - UINT32 Event, - FIXED_EVENT_HANDLER Handler, - void *Context) -{ - ACPI_STATUS Status = AE_OK; - - - FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); - - - /* Sanity check the parameters. */ - - if (Event >= NUM_FIXED_EVENTS) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_EVENTS); - - /* Don't allow two handlers. */ - - if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) - { - Status = AE_EXIST; - goto Cleanup; - } - - - /* Install the handler before enabling the event - just in case... */ - - AcpiGbl_FixedEventHandlers[Event].Handler = Handler; - AcpiGbl_FixedEventHandlers[Event].Context = Context; - - Status = AcpiEnableEvent(Event, ACPI_EVENT_FIXED); - - if (!ACPI_SUCCESS(Status)) - { - DEBUG_PRINT (ACPI_WARN, ("Could not enable fixed event.\n")); - - /* Remove the handler */ - - AcpiGbl_FixedEventHandlers[Event].Handler = NULL; - AcpiGbl_FixedEventHandlers[Event].Context = NULL; - - Status = AE_ERROR; - goto Cleanup; - } - - DEBUG_PRINT (ACPI_INFO, - ("Enabled fixed event %X, Handler=%p\n", Event, Handler)); - - -Cleanup: - AcpiCmReleaseMutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiRemoveFixedEventHandler - * - * PARAMETERS: Event - Event type to disable. - * Handler - Address of the handler - * - * RETURN: Status - * - * DESCRIPTION: Disables the event and unregisters the event handler. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiRemoveFixedEventHandler ( - UINT32 Event, - FIXED_EVENT_HANDLER Handler) -{ - ACPI_STATUS Status = AE_OK; - - - FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); - - - /* Sanity check the parameters. */ - - if (Event >= NUM_FIXED_EVENTS) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_EVENTS); - - /* Disable the event before removing the handler - just in case... */ - - Status = AcpiDisableEvent(Event, ACPI_EVENT_FIXED); - - if (!ACPI_SUCCESS(Status)) - { - DEBUG_PRINT (ACPI_WARN, - ("Could not write to fixed event enable register.\n")); - - Status = AE_ERROR; - AcpiCmReleaseMutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (Status); - } - - /* Remove the handler */ - - AcpiGbl_FixedEventHandlers[Event].Handler = NULL; - AcpiGbl_FixedEventHandlers[Event].Context = NULL; - - DEBUG_PRINT (ACPI_INFO, ("Disabled fixed event %X.\n", Event)); - - AcpiCmReleaseMutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiInstallNotifyHandler - * - * PARAMETERS: Device - The device for which notifies will be handled - * HandlerType - The type of handler: - * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) - * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) - * Handler - Address of the handler - * Context - Value passed to the handler on each GPE - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for notifies on an ACPI device - * - ******************************************************************************/ - -ACPI_STATUS -AcpiInstallNotifyHandler ( - ACPI_HANDLE Device, - UINT32 HandlerType, - NOTIFY_HANDLER Handler, - void *Context) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *NotifyObj; - ACPI_NAMESPACE_NODE *DeviceNode; - ACPI_STATUS Status = AE_OK; - - - FUNCTION_TRACE ("AcpiInstallNotifyHandler"); - - - /* Parameter validation */ - - if ((!Handler) || - (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - DeviceNode = AcpiNsConvertHandleToEntry (Device); - if (!DeviceNode) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* - * Root Object: - * ------------ - * Registering a notify handler on the root object indicates that the - * caller wishes to receive notifications for all objects. Note that - * only one <external> global handler can be regsitered (per notify type). - */ - if (Device == ACPI_ROOT_OBJECT) - { - /* Make sure the handler is not already installed */ - - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - AcpiGbl_SysNotify.Handler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && - AcpiGbl_DrvNotify.Handler)) - { - Status = AE_EXIST; - goto UnlockAndExit; - } - - if (HandlerType == ACPI_SYSTEM_NOTIFY) - { - AcpiGbl_SysNotify.Node = DeviceNode; - AcpiGbl_SysNotify.Handler = Handler; - AcpiGbl_SysNotify.Context = Context; - } - else /* ACPI_DEVICE_NOTIFY */ - { - AcpiGbl_DrvNotify.Node = DeviceNode; - AcpiGbl_DrvNotify.Handler = Handler; - AcpiGbl_DrvNotify.Context = Context; - } - - /* Global notify handler installed */ - } - - /* - * Other Objects: - * -------------- - * Caller will only receive notifications specific to the target object. - * Note that only certain object types can receive notifications. - */ - else { - /* - * These are the ONLY objects that can receive ACPI notifications - */ - if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && - (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && - (DeviceNode->Type != ACPI_TYPE_POWER) && - (DeviceNode->Type != ACPI_TYPE_THERMAL)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Check for an existing internal object */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); - if (ObjDesc) - { - - /* Object exists - make sure there's no handler */ - - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - ObjDesc->Device.SysHandler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && - ObjDesc->Device.DrvHandler)) - { - Status = AE_EXIST; - goto UnlockAndExit; - } - } - - else - { - /* Create a new object */ - - ObjDesc = AcpiCmCreateInternalObject (DeviceNode->Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Attach new object to the Node */ - - Status = AcpiNsAttachObject (Device, ObjDesc, (UINT8) DeviceNode->Type); - - if (ACPI_FAILURE (Status)) - { - goto UnlockAndExit; - } - } - - /* Install the handler */ - - NotifyObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_NOTIFY); - if (!NotifyObj) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - NotifyObj->NotifyHandler.Node = DeviceNode; - NotifyObj->NotifyHandler.Handler = Handler; - NotifyObj->NotifyHandler.Context = Context; - - - if (HandlerType == ACPI_SYSTEM_NOTIFY) - { - ObjDesc->Device.SysHandler = NotifyObj; - } - else /* ACPI_DEVICE_NOTIFY */ - { - ObjDesc->Device.DrvHandler = NotifyObj; - } - } - -UnlockAndExit: - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - - -/***************************************************************************** - * - * FUNCTION: AcpiRemoveNotifyHandler - * - * PARAMETERS: Device - The device for which notifies will be handled - * HandlerType - The type of handler: - * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) - * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) - * Handler - Address of the handler - * RETURN: Status - * - * DESCRIPTION: Remove a handler for notifies on an ACPI device - * - ******************************************************************************/ - -ACPI_STATUS -AcpiRemoveNotifyHandler ( - ACPI_HANDLE Device, - UINT32 HandlerType, - NOTIFY_HANDLER Handler) -{ - ACPI_OPERAND_OBJECT *NotifyObj; - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_NAMESPACE_NODE *DeviceNode; - ACPI_STATUS Status = AE_OK; - - FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); - - /* Parameter validation */ - - if ((!Handler) || - (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - DeviceNode = AcpiNsConvertHandleToEntry (Device); - if (!DeviceNode) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* - * Root Object: - * ------------ - */ - if (Device == ACPI_ROOT_OBJECT) { - - DEBUG_PRINT(ACPI_INFO, ("Removing notify handler for ROOT object.\n")); - - if (((HandlerType == ACPI_SYSTEM_NOTIFY) && - !AcpiGbl_SysNotify.Handler) || - ((HandlerType == ACPI_DEVICE_NOTIFY) && - !AcpiGbl_DrvNotify.Handler)) - { - Status = AE_NOT_EXIST; - goto UnlockAndExit; - } - - if (HandlerType == ACPI_SYSTEM_NOTIFY) { - AcpiGbl_SysNotify.Node = NULL; - AcpiGbl_SysNotify.Handler = NULL; - AcpiGbl_SysNotify.Context = NULL; - } - else { - AcpiGbl_DrvNotify.Node = NULL; - AcpiGbl_DrvNotify.Handler = NULL; - AcpiGbl_DrvNotify.Context = NULL; - } - } - - /* - * Other Objects: - * -------------- - */ - else { - /* - * These are the ONLY objects that can receive ACPI notifications - */ - if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && - (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && - (DeviceNode->Type != ACPI_TYPE_POWER) && - (DeviceNode->Type != ACPI_TYPE_THERMAL)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Check for an existing internal object */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) DeviceNode); - if (!ObjDesc) - { - Status = AE_NOT_EXIST; - goto UnlockAndExit; - } - - /* Object exists - make sure there's an existing handler */ - - if (HandlerType == ACPI_SYSTEM_NOTIFY) - { - NotifyObj = ObjDesc->Device.SysHandler; - } - else - { - NotifyObj = ObjDesc->Device.DrvHandler; - } - - if ((!NotifyObj) || - (NotifyObj->NotifyHandler.Handler != Handler)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* Remove the handler */ - - if (HandlerType == ACPI_SYSTEM_NOTIFY) - { - ObjDesc->Device.SysHandler = NULL; - } - else - { - ObjDesc->Device.DrvHandler = NULL; - } - - AcpiCmRemoveReference (NotifyObj); - } - - -UnlockAndExit: - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiInstallGpeHandler - * - * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is - * bank 0 first, then bank 1. - * Type - Whether this GPE should be treated as an - * edge- or level-triggered interrupt. - * Handler - Address of the handler - * Context - Value passed to the handler on each GPE - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for a General Purpose Event. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiInstallGpeHandler ( - UINT32 GpeNumber, - UINT32 Type, - GPE_HANDLER Handler, - void *Context) -{ - ACPI_STATUS Status = AE_OK; - - FUNCTION_TRACE ("AcpiInstallGpeHandler"); - - /* Parameter validation */ - - if (!Handler || (GpeNumber > NUM_GPE)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Ensure that we have a valid GPE number */ - - if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_EVENTS); - - /* Make sure that there isn't a handler there already */ - - if (AcpiGbl_GpeInfo[GpeNumber].Handler) - { - Status = AE_EXIST; - goto Cleanup; - } - - /* Install the handler */ - - AcpiGbl_GpeInfo[GpeNumber].Handler = Handler; - AcpiGbl_GpeInfo[GpeNumber].Context = Context; - AcpiGbl_GpeInfo[GpeNumber].Type = (UINT8) Type; - - /* Clear the GPE (of stale events), the enable it */ - - AcpiHwClearGpe (GpeNumber); - AcpiHwEnableGpe (GpeNumber); - -Cleanup: - AcpiCmReleaseMutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiRemoveGpeHandler - * - * PARAMETERS: GpeNumber - The event to remove a handler - * Handler - Address of the handler - * - * RETURN: Status - * - * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiRemoveGpeHandler ( - UINT32 GpeNumber, - GPE_HANDLER Handler) -{ - ACPI_STATUS Status = AE_OK; - - - FUNCTION_TRACE ("AcpiRemoveGpeHandler"); - - - /* Parameter validation */ - - if (!Handler || (GpeNumber > NUM_GPE)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Ensure that we have a valid GPE number */ - - if (AcpiGbl_GpeValid[GpeNumber] == ACPI_GPE_INVALID) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Disable the GPE before removing the handler */ - - AcpiHwDisableGpe (GpeNumber); - - AcpiCmAcquireMutex (ACPI_MTX_EVENTS); - - /* Make sure that the installed handler is the same */ - - if (AcpiGbl_GpeInfo[GpeNumber].Handler != Handler) - { - AcpiHwEnableGpe (GpeNumber); - Status = AE_BAD_PARAMETER; - goto Cleanup; - } - - /* Remove the handler */ - - AcpiGbl_GpeInfo[GpeNumber].Handler = NULL; - AcpiGbl_GpeInfo[GpeNumber].Context = NULL; - -Cleanup: - AcpiCmReleaseMutex (ACPI_MTX_EVENTS); - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiAcquireGlobalLock - * - * PARAMETERS: Timeout - How long the caller is willing to wait - * OutHandle - A handle to the lock if acquired - * - * RETURN: Status - * - * DESCRIPTION: Acquire the ACPI Global Lock - * - ******************************************************************************/ -ACPI_STATUS -AcpiAcquireGlobalLock ( - void) -{ - ACPI_STATUS Status; - - - AcpiAmlEnterInterpreter (); - - /* - * TBD: [Restructure] add timeout param to internal interface, and - * perhaps INTERPRETER_LOCKED - */ - - Status = AcpiEvAcquireGlobalLock (); - AcpiAmlExitInterpreter (); - - return (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiReleaseGlobalLock - * - * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock - * - * RETURN: Status - * - * DESCRIPTION: Release the ACPI Global Lock - * - ******************************************************************************/ - -ACPI_STATUS -AcpiReleaseGlobalLock ( - void) -{ - AcpiEvReleaseGlobalLock (); - return (AE_OK); -} - - diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c b/sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c deleted file mode 100644 index 463985d309dd2..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evxfevnt.c +++ /dev/null @@ -1,624 +0,0 @@ -/****************************************************************************** - * - * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * $Revision: 28 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial prton of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - - -#define __EVXFEVNT_C__ - -#include "acpi.h" -#include "achware.h" -#include "acnamesp.h" -#include "acevents.h" -#include "amlcode.h" -#include "acinterp.h" - -#define _COMPONENT EVENT_HANDLING - MODULE_NAME ("evxfevnt") - - -/************************************************************************** - * - * FUNCTION: AcpiEnable - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Transfers the system into ACPI mode. - * - *************************************************************************/ - -ACPI_STATUS -AcpiEnable (void) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("AcpiEnable"); - - - /* Make sure we've got ACPI tables */ - - if (!AcpiGbl_DSDT) - { - DEBUG_PRINT (ACPI_WARN, ("No ACPI tables present!\n")); - return_ACPI_STATUS (AE_NO_ACPI_TABLES); - } - - /* Make sure the BIOS supports ACPI mode */ - - if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities()) - { - DEBUG_PRINT (ACPI_WARN, - ("AcpiEnable: Only legacy mode supported!\n")); - return_ACPI_STATUS (AE_ERROR); - } - - /* Transition to ACPI mode */ - - Status = AcpiHwSetMode (SYS_MODE_ACPI); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_FATAL, ("Could not transition to ACPI mode.\n")); - return_ACPI_STATUS (Status); - } - - DEBUG_PRINT (ACPI_OK, ("Transition to ACPI mode successful\n")); - - return_ACPI_STATUS (Status); -} - - -/************************************************************************** - * - * FUNCTION: AcpiDisable - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Returns the system to original ACPI/legacy mode, and - * uninstalls the SCI interrupt handler. - * - *************************************************************************/ - -ACPI_STATUS -AcpiDisable (void) -{ - ACPI_STATUS Status; - - - FUNCTION_TRACE ("AcpiDisable"); - - - /* Restore original mode */ - - Status = AcpiHwSetMode (AcpiGbl_OriginalMode); - if (ACPI_FAILURE (Status)) - { - DEBUG_PRINT (ACPI_ERROR, ("Unable to transition to original mode")); - return_ACPI_STATUS (Status); - } - - /* Unload the SCI interrupt handler */ - - AcpiEvRemoveSciHandler (); - AcpiEvRestoreAcpiState (); - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiEnableEvent - * - * PARAMETERS: Event - The fixed event or GPE to be enabled - * Type - The type of event - * - * RETURN: Status - * - * DESCRIPTION: Enable an ACPI event (fixed and general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiEnableEvent ( - UINT32 Event, - UINT32 Type) -{ - ACPI_STATUS Status = AE_OK; - UINT32 RegisterId; - - - FUNCTION_TRACE ("AcpiEnableEvent"); - - - /* The Type must be either Fixed AcpiEvent or GPE */ - - switch (Type) - { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed AcpiEvent */ - - switch (Event) - { - case ACPI_EVENT_PMTIMER: - RegisterId = TMR_EN; - break; - - case ACPI_EVENT_GLOBAL: - RegisterId = GBL_EN; - break; - - case ACPI_EVENT_POWER_BUTTON: - RegisterId = PWRBTN_EN; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - RegisterId = SLPBTN_EN; - break; - - case ACPI_EVENT_RTC: - RegisterId = RTC_EN; - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - break; - } - - /* - * Enable the requested fixed event (by writing a one to the - * enable register bit) - */ - - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 1); - - if (1 != AcpiHwRegisterBitAccess(ACPI_READ, ACPI_MTX_LOCK, RegisterId)) - { - DEBUG_PRINT(ACPI_ERROR, ("Fixed event bit clear when it should be set,\n")); - return_ACPI_STATUS (AE_ERROR); - } - - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((Event >= NUM_GPE) || - (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* Enable the requested GPE number */ - - AcpiHwEnableGpe (Event); - break; - - - default: - - Status = AE_BAD_PARAMETER; - } - - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiDisableEvent - * - * PARAMETERS: Event - The fixed event or GPE to be enabled - * Type - The type of event - * - * RETURN: Status - * - * DESCRIPTION: Disable an ACPI event (fixed and general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDisableEvent ( - UINT32 Event, - UINT32 Type) -{ - ACPI_STATUS Status = AE_OK; - UINT32 RegisterId; - - - FUNCTION_TRACE ("AcpiDisableEvent"); - - - /* The Type must be either Fixed AcpiEvent or GPE */ - - switch (Type) - { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed AcpiEvent */ - - switch (Event) - { - case ACPI_EVENT_PMTIMER: - RegisterId = TMR_EN; - break; - - case ACPI_EVENT_GLOBAL: - RegisterId = GBL_EN; - break; - - case ACPI_EVENT_POWER_BUTTON: - RegisterId = PWRBTN_EN; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - RegisterId = SLPBTN_EN; - break; - - case ACPI_EVENT_RTC: - RegisterId = RTC_EN; - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - break; - } - - /* - * Disable the requested fixed event (by writing a zero to the - * enable register bit) - */ - - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 0); - - if (0 != AcpiHwRegisterBitAccess(ACPI_READ, ACPI_MTX_LOCK, RegisterId)) - { - DEBUG_PRINT(ACPI_ERROR, ("Fixed event bit set when it should be clear,\n")); - return_ACPI_STATUS (AE_ERROR); - } - - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((Event >= NUM_GPE) || - (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - /* Disable the requested GPE number */ - - AcpiHwDisableGpe (Event); - break; - - - default: - Status = AE_BAD_PARAMETER; - } - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiClearEvent - * - * PARAMETERS: Event - The fixed event or GPE to be cleared - * Type - The type of event - * - * RETURN: Status - * - * DESCRIPTION: Clear an ACPI event (fixed and general purpose) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiClearEvent ( - UINT32 Event, - UINT32 Type) -{ - ACPI_STATUS Status = AE_OK; - UINT32 RegisterId; - - - FUNCTION_TRACE ("AcpiClearEvent"); - - - /* The Type must be either Fixed AcpiEvent or GPE */ - - switch (Type) - { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed AcpiEvent */ - - switch (Event) - { - case ACPI_EVENT_PMTIMER: - RegisterId = TMR_STS; - break; - - case ACPI_EVENT_GLOBAL: - RegisterId = GBL_STS; - break; - - case ACPI_EVENT_POWER_BUTTON: - RegisterId = PWRBTN_STS; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - RegisterId = SLPBTN_STS; - break; - - case ACPI_EVENT_RTC: - RegisterId = RTC_STS; - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - break; - } - - /* - * Clear the requested fixed event (By writing a one to the - * status register bit) - */ - - AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 1); - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((Event >= NUM_GPE) || - (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - AcpiHwClearGpe (Event); - break; - - - default: - - Status = AE_BAD_PARAMETER; - } - - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiGetEventStatus - * - * PARAMETERS: Event - The fixed event or GPE - * Type - The type of event - * Status - Where the current status of the event will - * be returned - * - * RETURN: Status - * - * DESCRIPTION: Obtains and returns the current status of the event - * - ******************************************************************************/ - - -ACPI_STATUS -AcpiGetEventStatus ( - UINT32 Event, - UINT32 Type, - ACPI_EVENT_STATUS *EventStatus) -{ - ACPI_STATUS Status = AE_OK; - UINT32 RegisterId; - - - FUNCTION_TRACE ("AcpiGetEventStatus"); - - - if (!EventStatus) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* The Type must be either Fixed AcpiEvent or GPE */ - - switch (Type) - { - - case ACPI_EVENT_FIXED: - - /* Decode the Fixed AcpiEvent */ - - switch (Event) - { - case ACPI_EVENT_PMTIMER: - RegisterId = TMR_STS; - break; - - case ACPI_EVENT_GLOBAL: - RegisterId = GBL_STS; - break; - - case ACPI_EVENT_POWER_BUTTON: - RegisterId = PWRBTN_STS; - break; - - case ACPI_EVENT_SLEEP_BUTTON: - RegisterId = SLPBTN_STS; - break; - - case ACPI_EVENT_RTC: - RegisterId = RTC_STS; - break; - - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); - break; - } - - /* Get the status of the requested fixed event */ - - *EventStatus = AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, RegisterId); - break; - - - case ACPI_EVENT_GPE: - - /* Ensure that we have a valid GPE number */ - - if ((Event >= NUM_GPE) || - (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - - /* Obtain status on the requested GPE number */ - - AcpiHwGetGpeStatus (Event, EventStatus); - break; - - - default: - Status = AE_BAD_PARAMETER; - } - - - return_ACPI_STATUS (Status); -} - diff --git a/sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c b/sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c deleted file mode 100644 index 7c05f5064d8df..0000000000000 --- a/sys/contrib/dev/acpica/Subsystem/Events/evxfregn.c +++ /dev/null @@ -1,515 +0,0 @@ -/****************************************************************************** - * - * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and - * Address Spaces. - * $Revision: 27 $ - * - *****************************************************************************/ - -/****************************************************************************** - * - * 1. Copyright Notice - * - * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. - * All rights reserved. - * - * 2. License - * - * 2.1. This is your license from Intel Corp. under its intellectual property - * rights. You may have additional license terms from the party that provided - * you this software, covering your right to use that party's intellectual - * property rights. - * - * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a - * copy of the source code appearing in this file ("Covered Code") an - * irrevocable, perpetual, worldwide license under Intel's copyrights in the - * base code distributed originally by Intel ("Original Intel Code") to copy, - * make derivatives, distribute, use and display any portion of the Covered - * Code in any form, with the right to sublicense such rights; and - * - * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent - * license (with the right to sublicense), under only those claims of Intel - * patents that are infringed by the Original Intel Code, to make, use, sell, - * offer to sell, and import the Covered Code and derivative works thereof - * solely to the minimum extent necessary to exercise the above copyright - * license, and in no event shall the patent license extend to any additions - * to or modifications of the Original Intel Code. No other license or right - * is granted directly or by implication, estoppel or otherwise; - * - * The above copyright and patent license is granted only if the following - * conditions are met: - * - * 3. Conditions - * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. - * Redistribution of source code of any substantial prton of the Covered - * Code or modification with rights to further distribute source must include - * the above Copyright Notice, the above License, this list of Conditions, - * and the following Disclaimer and Export Compliance provision. In addition, - * Licensee must cause all Covered Code to which Licensee contributes to - * contain a file documenting the changes Licensee made to create that Covered - * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee - * must include a prominent statement that the modification is derived, - * directly or indirectly, from Original Intel Code. - * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. - * Redistribution of source code of any substantial portion of the Covered - * Code or modification without rights to further distribute source must - * include the following Disclaimer and Export Compliance provision in the - * documentation and/or other materials provided with distribution. In - * addition, Licensee may not authorize further sublicense of source of any - * portion of the Covered Code, and must include terms to the effect that the - * license from Licensee to its licensee is limited to the intellectual - * property embodied in the software Licensee provides to its licensee, and - * not to intellectual property embodied in modifications its licensee may - * make. - * - * 3.3. Redistribution of Executable. Redistribution in executable form of any - * substantial portion of the Covered Code or modification must reproduce the - * above Copyright Notice, and the following Disclaimer and Export Compliance - * provision in the documentation and/or other materials provided with the - * distribution. - * - * 3.4. Intel retains all right, title, and interest in and to the Original - * Intel Code. - * - * 3.5. Neither the name Intel nor any other trademark owned or controlled by - * Intel shall be used in advertising or otherwise to promote the sale, use or - * other dealings in products derived from or relating to the Covered Code - * without prior written authorization from Intel. - * - * 4. Disclaimer and Export Compliance - * - * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED - * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE - * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, - * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY - * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY - * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. - * - * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES - * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR - * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, - * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY - * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL - * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS - * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY - * LIMITED REMEDY. - * - * 4.3. Licensee shall not export, either directly or indirectly, any of this - * software or system incorporating such software without first obtaining any - * required license or other approval from the U. S. Department of Commerce or - * any other agency or department of the United States Government. In the - * event Licensee exports any such software from the United States or - * re-exports any such software from a foreign destination, Licensee shall - * ensure that the distribution and export/re-export of the software is in - * compliance with all laws, regulations, orders, or other restrictions of the - * U.S. Export Administration Regulations. Licensee agrees that neither it nor - * any of its subsidiaries will export/re-export any technical data, process, - * software, or service, directly or indirectly, to any country for which the - * United States government or any agency thereof requires an export license, - * other governmental approval, or letter of assurance, without first obtaining - * such license, approval or letter. - * - *****************************************************************************/ - -#define __EVXFREGN_C__ - -#include "acpi.h" -#include "achware.h" -#include "acnamesp.h" -#include "acevents.h" -#include "amlcode.h" -#include "acinterp.h" - -#define _COMPONENT EVENT_HANDLING - 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. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiInstallAddressSpaceHandler ( - ACPI_HANDLE Device, - ACPI_ADDRESS_SPACE_TYPE SpaceId, - ADDRESS_SPACE_HANDLER Handler, - ADDRESS_SPACE_SETUP Setup, - void *Context) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status = AE_OK; - OBJECT_TYPE_INTERNAL Type; - UINT16 Flags = 0; - - - FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); - - /* Parameter validation */ - - if ((!Device) || - ((!Handler) && (Handler != ACPI_DEFAULT_HANDLER)) || - (SpaceId > ACPI_MAX_ADDRESS_SPACE)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - Node = AcpiNsConvertHandleToEntry (Device); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - /* - * This registration is valid for only the types below - * and the root. This is where the default handlers - * get placed. - */ - - if ((Node->Type != ACPI_TYPE_DEVICE) && - (Node->Type != ACPI_TYPE_PROCESSOR) && - (Node->Type != ACPI_TYPE_THERMAL) && - (Node != AcpiGbl_RootNode)) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - if (Handler == ACPI_DEFAULT_HANDLER) - { - Flags = ADDR_HANDLER_DEFAULT_INSTALLED; - - switch (SpaceId) - { - case ADDRESS_SPACE_SYSTEM_MEMORY: - Handler = AcpiAmlSystemMemorySpaceHandler; - Setup = AcpiEvSystemMemoryRegionSetup; - break; - - case ADDRESS_SPACE_SYSTEM_IO: - Handler = AcpiAmlSystemIoSpaceHandler; - Setup = AcpiEvIoSpaceRegionSetup; - break; - - case ADDRESS_SPACE_PCI_CONFIG: - Handler = AcpiAmlPciConfigSpaceHandler; - Setup = AcpiEvPciConfigRegionSetup; - break; - - default: - Status = AE_NOT_EXIST; - goto UnlockAndExit; - break; - } - } - - /* - * If the caller hasn't specified a setup routine, use the default - */ - if (!Setup) - { - Setup = AcpiEvDefaultRegionSetup; - } - - /* - * Check for an existing internal object - */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); - if (ObjDesc) - { - /* - * The object exists. - * Make sure the handler is not already installed. - */ - - /* check the address handler the user requested */ - - HandlerObj = ObjDesc->Device.AddrHandler; - while (HandlerObj) - { - /* - * We have an Address handler, see if user requested this - * address space. - */ - if(HandlerObj->AddrHandler.SpaceId == SpaceId) - { - Status = AE_EXIST; - goto UnlockAndExit; - } - - /* - * Move through the linked list of handlers - */ - HandlerObj = HandlerObj->AddrHandler.Next; - } - } - - else - { - DEBUG_PRINT (TRACE_OPREGION, - ("Creating object on Device %p while installing handler\n", - Node)); - - /* ObjDesc does not exist, create one */ - - if (Node->Type == ACPI_TYPE_ANY) - { - Type = ACPI_TYPE_DEVICE; - } - - else - { - Type = Node->Type; - } - - ObjDesc = AcpiCmCreateInternalObject (Type); - if (!ObjDesc) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - /* Init new descriptor */ - - ObjDesc->Common.Type = (UINT8) Type; - - /* Attach the new object to the Node */ - - Status = AcpiNsAttachObject (Node, ObjDesc, (UINT8) Type); - if (ACPI_FAILURE (Status)) - { - AcpiCmRemoveReference (ObjDesc); - goto UnlockAndExit; - } - } - - DEBUG_PRINT (TRACE_OPREGION, - ("Installing address handler for region %s(%X) on Device %p(%p)\n", - AcpiCmGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); - - /* - * Now we can install the handler - * - * At this point we know that there is no existing handler. - * So, we just allocate the object for the handler and link it - * into the list. - */ - HandlerObj = AcpiCmCreateInternalObject (INTERNAL_TYPE_ADDRESS_HANDLER); - if (!HandlerObj) - { - Status = AE_NO_MEMORY; - goto UnlockAndExit; - } - - HandlerObj->AddrHandler.SpaceId = (UINT8) SpaceId; - HandlerObj->AddrHandler.Hflags = Flags; - HandlerObj->AddrHandler.Next = ObjDesc->Device.AddrHandler; - HandlerObj->AddrHandler.RegionList = NULL; - HandlerObj->AddrHandler.Node = Node; - HandlerObj->AddrHandler.Handler = Handler; - HandlerObj->AddrHandler.Context = Context; - HandlerObj->AddrHandler.Setup = Setup; - - /* - * Now walk the namespace finding all of the regions this - * handler will manage. - * - * We start at the device and search the branch toward - * the leaf nodes until either the leaf is encountered or - * a device is detected that has an address handler of the - * same type. - * - * In either case we back up and search down the remainder - * of the branch - */ - Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, - ACPI_UINT32_MAX, NS_WALK_UNLOCK, - AcpiEvAddrHandlerHelper, - HandlerObj, NULL); - - /* - * Place this handler 1st on the list - */ - - HandlerObj->Common.ReferenceCount = - (UINT16) (HandlerObj->Common.ReferenceCount + - ObjDesc->Common.ReferenceCount - 1); - ObjDesc->Device.AddrHandler = HandlerObj; - - -UnlockAndExit: - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - - -/****************************************************************************** - * - * FUNCTION: AcpiRemoveAddressSpaceHandler - * - * PARAMETERS: SpaceId - The address space ID - * Handler - Address of the handler - * - * RETURN: Status - * - * DESCRIPTION: Install a handler for accesses on an Operation Region - * - ******************************************************************************/ - -ACPI_STATUS -AcpiRemoveAddressSpaceHandler ( - ACPI_HANDLE Device, - ACPI_ADDRESS_SPACE_TYPE SpaceId, - ADDRESS_SPACE_HANDLER Handler) -{ - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_OPERAND_OBJECT *HandlerObj; - ACPI_OPERAND_OBJECT *RegionObj; - ACPI_OPERAND_OBJECT **LastObjPtr; - ACPI_NAMESPACE_NODE *Node; - ACPI_STATUS Status = AE_OK; - - - FUNCTION_TRACE ("AcpiRemoveAddressSpaceHandler"); - - - /* Parameter validation */ - - if ((!Device) || - ((!Handler) && (Handler != ACPI_DEFAULT_HANDLER)) || - (SpaceId > ACPI_MAX_ADDRESS_SPACE)) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE); - - /* Convert and validate the device handle */ - - Node = AcpiNsConvertHandleToEntry (Device); - if (!Node) - { - Status = AE_BAD_PARAMETER; - goto UnlockAndExit; - } - - - /* Make sure the internal object exists */ - - ObjDesc = AcpiNsGetAttachedObject ((ACPI_HANDLE) Node); - if (!ObjDesc) - { - /* - * The object DNE. - */ - Status = AE_NOT_EXIST; - goto UnlockAndExit; - } - - /* - * find the address handler the user requested - */ - - HandlerObj = ObjDesc->Device.AddrHandler; - LastObjPtr = &ObjDesc->Device.AddrHandler; - while (HandlerObj) - { - /* - * We have a handler, see if user requested this one - */ - - if(HandlerObj->AddrHandler.SpaceId == SpaceId) - { - /* - * Got it, first dereference this in the Regions - */ - DEBUG_PRINT (TRACE_OPREGION, - ("Removing address handler %p(%p) for region %s on Device %p(%p)\n", - HandlerObj, Handler, AcpiCmGetRegionName (SpaceId), - Node, ObjDesc)); - - RegionObj = HandlerObj->AddrHandler.RegionList; - - /* 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 - */ - AcpiEvDisassociateRegionFromHandler(RegionObj, FALSE); - - /* - * Walk the list, since we took the first region and it - * was removed from the list by the dissassociate call - * we just get the first item on the list again - */ - RegionObj = HandlerObj->AddrHandler.RegionList; - - } - - /* - * Remove this Handler object from the list - */ - *LastObjPtr = HandlerObj->AddrHandler.Next; - - /* - * Now we can delete the handler object - */ - AcpiCmRemoveReference (HandlerObj); - AcpiCmRemoveReference (HandlerObj); - - goto UnlockAndExit; - } - - /* - * Move through the linked list of handlers - */ - LastObjPtr = &HandlerObj->AddrHandler.Next; - HandlerObj = HandlerObj->AddrHandler.Next; - } - - - /* - * The handler does not exist - */ - DEBUG_PRINT (TRACE_OPREGION, - ("Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n", - Handler, AcpiCmGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); - - Status = AE_NOT_EXIST; - - -UnlockAndExit: - AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE); - return_ACPI_STATUS (Status); -} - - |