From owner-acpi-jp@jp.freebsd.org  Mon Oct 30 21:25:15 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id VAA66517;
	Mon, 30 Oct 2000 21:25:15 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from shidahara1.planet.sci.kobe-u.ac.jp (shidahara1.planet.sci.kobe-u.ac.jp [133.30.50.200])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id VAA66512
	for <acpi-jp@jp.freebsd.org>; Mon, 30 Oct 2000 21:25:15 +0900 (JST)
	(envelope-from takawata@shidahara1.planet.sci.kobe-u.ac.jp)
Received: from shidahara1.planet.sci.kobe-u.ac.jp (localhost [127.0.0.1])
	by shidahara1.planet.sci.kobe-u.ac.jp (8.9.3/8.9.3) with ESMTP id VAA00664;
	Mon, 30 Oct 2000 21:25:14 +0900 (JST)
	(envelope-from takawata@shidahara1.planet.sci.kobe-u.ac.jp)
Message-Id: <200010301225.VAA00664@shidahara1.planet.sci.kobe-u.ac.jp>
To: "Grover, Andrew" <andrew.grover@intel.com>
cc: acpi-jp@jp.freebsd.org
Date: Mon, 30 Oct 2000 21:25:14 +0900
From: Takanori Watanabe <takawata@shidahara1.planet.sci.kobe-u.ac.jp>
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 892
Subject: [acpi-jp 892] GPE handler directly invocation.
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: takawata@shidahara1.planet.sci.kobe-u.ac.jp

Hi,

I want to use GPE interrupt directly ,not queued one, 
in installed GPE handler to use interrupt Embedded controller reading/writing.

So I wrote this patch, is it OK?
This is contained in my previous post,And,with the patchset,
Embedded controller workes without performance loss.(though 
the execution itself is a bit slow,But it is not serious problem.)

Takanori Watanabe
<a href="http://www.planet.sci.kobe-u.ac.jp/~takawata/key.html">
Public Key</a>
Key fingerprint =  2C 51 E2 78 2C E1 C5 2D  0F F1 20 A3 11 3A 62 2A 


diff -ru contrib/dev/acpica/Subsystem/Events/evevent.c sys/contrib/dev/acpica/Subsystem/Events/evevent.c
--- contrib/dev/acpica/Subsystem/Events/evevent.c	Tue Oct  3 14:30:01 2000
+++ sys/contrib/dev/acpica/Subsystem/Events/evevent.c	Thu Oct 19 22:47:48 2000
@@ -805,21 +805,11 @@
     AcpiCmReleaseMutex (ACPI_MTX_EVENTS);
 
     /*
-     * Function Handler (e.g. EC):
-     * ---------------------------
-     * Execute the installed function handler to handle this event.
-     */
-    if (GpeInfo.Handler)
-    {
-        GpeInfo.Handler (GpeInfo.Context);
-    }
-
-    /*
      * Method Handler (_Lxx, _Exx):
      * ----------------------------
      * AcpiEvaluate the _Lxx/_Exx control method that corresponds to this GPE.
      */
-    else if (GpeInfo.MethodHandle)
+    if (GpeInfo.MethodHandle)
     {
         AcpiNsEvaluateByHandle (GpeInfo.MethodHandle, NULL, NULL);
     }
@@ -906,8 +896,7 @@
      * Queue the handler, which is either an installable function handler
      * (e.g. EC) or a control method (e.g. _Lxx/_Exx) for later execution.
      */
-    if (AcpiGbl_GpeInfo [GpeNumber].Handler ||
-        AcpiGbl_GpeInfo [GpeNumber].MethodHandle)
+    if (AcpiGbl_GpeInfo [GpeNumber].MethodHandle)
     {
         if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE,
                                             AcpiEvAsynchExecuteGpeMethod,
@@ -922,8 +911,23 @@
                 ("EvGpeDispatch: Unable to queue the handler for GPE [0x%08X]\n",
                 GpeNumber));
         }
-    }
+    }else if( AcpiGbl_GpeInfo [GpeNumber].Handler ) {
+	    ACPI_GPE_LEVEL_INFO GpeInfo;
+	    /*
+	     * Function Handler (e.g. EC):
+	     * ---------------------------
+	     * Execute the installed function handler to handle this event.
+	     * Without queueing.
+	     */
+	    AcpiCmAcquireMutex (ACPI_MTX_EVENTS);
+	    GpeInfo = AcpiGbl_GpeInfo [GpeNumber];
+	    AcpiCmReleaseMutex (ACPI_MTX_EVENTS);
+	    
+	    if (GpeInfo.Handler){
+		    GpeInfo.Handler (GpeInfo.Context);
+	    }
 
+    }
     /*
      * Non Handled GPEs:
      * -----------------
