patch-2.4.22 linux-2.4.22/drivers/acpi/events/evsci.c

Next file: linux-2.4.22/drivers/acpi/events/evxface.c
Previous file: linux-2.4.22/drivers/acpi/events/evrgnini.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.21/drivers/acpi/events/evsci.c linux-2.4.22/drivers/acpi/events/evsci.c
@@ -2,281 +2,198 @@
  *
  * Module Name: evsci - System Control Interrupt configuration and
  *                      legacy to ACPI mode state transition functions
- *              $Revision: 74 $
  *
  ******************************************************************************/
 
 /*
- *  Copyright (C) 2000, 2001 R. Byron Moore
+ * Copyright (C) 2000 - 2003, R. Byron Moore
+ * All rights reserved.
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
  */
 
-#include "acpi.h"
-#include "acnamesp.h"
-#include "achware.h"
-#include "acevents.h"
+#include <acpi/acpi.h>
+#include <acpi/acevents.h>
 
 
 #define _COMPONENT          ACPI_EVENTS
-	 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
- */
+	 ACPI_MODULE_NAME    ("evsci")
 
 
 /*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_sci_handler
+ * FUNCTION:    acpi_ev_sci_xrupt_handler
  *
  * 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.
+ *              control method to call to deal with a SCI.
  *
  ******************************************************************************/
 
-static u32
-acpi_ev_sci_handler (void *context)
+static u32 ACPI_SYSTEM_XFACE
+acpi_ev_sci_xrupt_handler (
+	void                            *context)
 {
-	u32                     interrupt_handled = INTERRUPT_NOT_HANDLED;
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_list = context;
+	u32                             interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
 
 
-	FUNCTION_TRACE("Ev_sci_handler");
+	ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
 
 
 	/*
-	 * 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.
+	 * We are guaranteed by the ACPI CA initialization/shutdown code that
+	 * if this interrupt handler is installed, ACPI is enabled.
 	 */
-	if (!acpi_hw_register_bit_access (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 Acpi_events:
-	 * -------------
-	 * Check for and dispatch any Fixed Acpi_events that have occurred
+	 * Fixed Events:
+	 * Check for and dispatch any Fixed Events that have occurred
 	 */
 	interrupt_handled |= acpi_ev_fixed_event_detect ();
 
 	/*
-	 * GPEs:
-	 * -----
+	 * General Purpose Events:
 	 * Check for and dispatch any GPEs that have occurred
 	 */
-	interrupt_handled |= acpi_ev_gpe_detect ();
+	interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
 
 	return_VALUE (interrupt_handled);
 }
 
 
-/******************************************************************************
- *
- * FUNCTION:    Acpi_ev_install_sci_handler
- *
- * PARAMETERS:  none
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Installs SCI handler.
- *
- ******************************************************************************/
-
-u32
-acpi_ev_install_sci_handler (void)
-{
-	u32                     status = AE_OK;
-
-
-	FUNCTION_TRACE ("Ev_install_sci_handler");
-
-
-	status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
-			   acpi_ev_sci_handler, NULL);
-	return_ACPI_STATUS (status);
-}
-
-
-/******************************************************************************
-
+/*******************************************************************************
  *
- * FUNCTION:    Acpi_ev_remove_sci_handler
+ * FUNCTION:    acpi_ev_gpe_xrupt_handler
  *
- * PARAMETERS:  none
+ * PARAMETERS:  Context   - Calling Context
  *
- * RETURN:      E_OK if handler uninstalled OK, E_ERROR if handler was not
- *              installed to begin with
+ * RETURN:      Status code indicates whether interrupt was handled.
  *
- * DESCRIPTION: Restores original status of all fixed event enable bits and
- *              removes SCI handler.
+ * DESCRIPTION: Handler for GPE Block Device interrupts
  *
  ******************************************************************************/
 
-acpi_status
-acpi_ev_remove_sci_handler (void)
+u32 ACPI_SYSTEM_XFACE
+acpi_ev_gpe_xrupt_handler (
+	void                            *context)
 {
-	FUNCTION_TRACE ("Ev_remove_sci_handler");
-
+	struct acpi_gpe_xrupt_info      *gpe_xrupt_list = context;
+	u32                             interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
 
-#if 0
-	/* TBD:[Investigate] Figure this out!!  Disable all events first ???  */
 
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (TMR_FIXED_EVENT)) {
-		acpi_event_disable_event (TMR_FIXED_EVENT);
-	}
+	ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
 
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (GBL_FIXED_EVENT)) {
-		acpi_event_disable_event (GBL_FIXED_EVENT);
-	}
 
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (PWR_BTN_FIXED_EVENT)) {
-		acpi_event_disable_event (PWR_BTN_FIXED_EVENT);
-	}
-
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (SLP_BTN_FIXED_EVENT)) {
-		acpi_event_disable_event (SLP_BTN_FIXED_EVENT);
-	}
-
-	if (original_fixed_enable_bit_status ^ 1 << acpi_event_index (RTC_FIXED_EVENT)) {
-		acpi_event_disable_event (RTC_FIXED_EVENT);
-	}
-
-	original_fixed_enable_bit_status = 0;
-
-#endif
+	/*
+	 * We are guaranteed by the ACPI CA initialization/shutdown code that
+	 * if this interrupt handler is installed, ACPI is enabled.
+	 */
 
-	acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
-			   acpi_ev_sci_handler);
+	/*
+	 * GPEs:
+	 * Check for and dispatch any GPEs that have occurred
+	 */
+	interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
 
-	return_ACPI_STATUS (AE_OK);
+	return_VALUE (interrupt_handled);
 }
 
 
-/*******************************************************************************
+/******************************************************************************
  *
- * FUNCTION:    Acpi_ev_restore_acpi_state
+ * FUNCTION:    acpi_ev_install_sci_handler
  *
  * PARAMETERS:  none
  *
- * RETURN:      none
+ * RETURN:      Status
  *
- * DESCRIPTION: Restore the original ACPI state of the machine
+ * DESCRIPTION: Installs SCI handler.
  *
  ******************************************************************************/
 
-void
-acpi_ev_restore_acpi_state (void)
+u32
+acpi_ev_install_sci_handler (void)
 {
-	u32                     index;
-
-
-	FUNCTION_TRACE ("Ev_restore_acpi_state");
-
-
-	/* Restore the state of the chipset enable bits. */
+	u32                             status = AE_OK;
 
-	if (acpi_gbl_restore_acpi_chipset == TRUE) {
-		/* Restore the fixed events */
 
-		if (acpi_hw_register_read (ACPI_MTX_LOCK, PM1_EN) !=
-				acpi_gbl_pm1_enable_register_save) {
-			acpi_hw_register_write (ACPI_MTX_LOCK, PM1_EN,
-				acpi_gbl_pm1_enable_register_save);
-		}
+	ACPI_FUNCTION_TRACE ("ev_install_sci_handler");
 
 
-		/* Ensure that all status bits are clear */
-
-		acpi_hw_clear_acpi_status ();
-
-
-		/* Now restore the GPEs */
-
-		for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe0blk_len); index++) {
-			if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index) !=
-					acpi_gbl_gpe0enable_register_save[index]) {
-				acpi_hw_register_write (ACPI_MTX_LOCK, GPE0_EN_BLOCK | index,
-					acpi_gbl_gpe0enable_register_save[index]);
-			}
-		}
-
-		/* GPE 1 present? */
-
-		if (acpi_gbl_FADT->gpe1_blk_len) {
-			for (index = 0; index < DIV_2 (acpi_gbl_FADT->gpe1_blk_len); index++) {
-				if (acpi_hw_register_read (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index) !=
-					acpi_gbl_gpe1_enable_register_save[index]) {
-					acpi_hw_register_write (ACPI_MTX_LOCK, GPE1_EN_BLOCK | index,
-						acpi_gbl_gpe1_enable_register_save[index]);
-				}
-			}
-		}
-
-		if (acpi_hw_get_mode() != acpi_gbl_original_mode) {
-			acpi_hw_set_mode (acpi_gbl_original_mode);
-		}
-	}
-
-	return_VOID;
+	status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
+			   acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head);
+	return_ACPI_STATUS (status);
 }
 
 
 /******************************************************************************
  *
- * FUNCTION:    Acpi_ev_terminate
+ * FUNCTION:    acpi_ev_remove_sci_handler
  *
  * PARAMETERS:  none
  *
- * RETURN:      none
+ * RETURN:      E_OK if handler uninstalled OK, E_ERROR if handler was not
+ *              installed to begin with
+ *
+ * DESCRIPTION: Remove the SCI interrupt handler.  No further SCIs will be
+ *              taken.
  *
- * DESCRIPTION: free memory allocated for table storage.
+ * Note:  It doesn't seem important to disable all events or set the event
+ *        enable registers to their original values.  The OS should disable
+ *        the SCI interrupt level when the handler is removed, so no more
+ *        events will come in.
  *
  ******************************************************************************/
 
-void
-acpi_ev_terminate (void)
+acpi_status
+acpi_ev_remove_sci_handler (void)
 {
+	acpi_status                     status;
 
-	FUNCTION_TRACE ("Ev_terminate");
 
+	ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
 
-	/*
-	 * Free global tables, etc.
-	 */
-	if (acpi_gbl_gpe_registers) {
-		ACPI_MEM_FREE (acpi_gbl_gpe_registers);
-	}
-
-	if (acpi_gbl_gpe_info) {
-		ACPI_MEM_FREE (acpi_gbl_gpe_info);
-	}
 
-	return_VOID;
+	/* Just let the OS remove the handler and disable the level */
+
+	status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
+			   acpi_ev_sci_xrupt_handler);
+
+	return_ACPI_STATUS (status);
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)