[ros-diffs] [cfinck] 32718: - Simplify the code for connecting the interrupts. Don't use three code pathes (keyboard; mouse; keyboard & mouse) anymore and don't check again in EnableInterrupts(), which devices are present. Instead prepare the flags for i8042ChangeMode() already in StartProcedure() and pass them later. - Constify the result of CTRL_SELF_TEST (0x55) as KBD_SELF_TEST_OK. - Add a bug number as a reference for the system flag setting.

cfinck at svn.reactos.org cfinck at svn.reactos.org
Tue Mar 18 13:00:29 CET 2008


Author: cfinck
Date: Tue Mar 18 07:00:29 2008
New Revision: 32718

URL: http://svn.reactos.org/svn/reactos?rev=3D32718&view=3Drev
Log:
- Simplify the code for connecting the interrupts.
  Don't use three code pathes (keyboard; mouse; keyboard & mouse) anymore a=
nd don't check again in EnableInterrupts(), which devices are present.
  Instead prepare the flags for i8042ChangeMode() already in StartProcedure=
() and pass them later.
- Constify the result of CTRL_SELF_TEST (0x55) as KBD_SELF_TEST_OK.
- Add a bug number as a reference for the system flag setting.

Modified:
    trunk/reactos/drivers/input/i8042prt/i8042prt.h
    trunk/reactos/drivers/input/i8042prt/pnp.c

Modified: trunk/reactos/drivers/input/i8042prt/i8042prt.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042pr=
t/i8042prt.h?rev=3D32718&r1=3D32717&r2=3D32718&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/input/i8042prt/i8042prt.h (original)
+++ trunk/reactos/drivers/input/i8042prt/i8042prt.h Tue Mar 18 07:00:29 2008
@@ -240,6 +240,7 @@
  * Keyboard responses
  * --------------------------------------------------*/
 =

+#define KBD_SELF_TEST_OK   0x55
 #define KBD_ACK            0xFA
 #define KBD_NACK           0xFC
 #define KBD_RESEND         0xFE

Modified: trunk/reactos/drivers/input/i8042prt/pnp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042pr=
t/pnp.c?rev=3D32718&r1=3D32717&r2=3D32718&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/drivers/input/i8042prt/pnp.c (original)
+++ trunk/reactos/drivers/input/i8042prt/pnp.c Tue Mar 18 07:00:29 2008
@@ -106,7 +106,7 @@
 			KeStallExecutionProcessor(50);
 			continue;
 		}
-		else if (Value !=3D 0x55)
+		else if (Value !=3D KBD_SELF_TEST_OK)
 		{
 			WARN_(I8042PRT, "Got 0x%02x instead of 0x55\n", Value);
 			return STATUS_IO_DEVICE_ERROR;
@@ -156,7 +156,7 @@
 		WARN_(I8042PRT, "Warning: can't write SET_LEDS (0x%08lx)\n", Status);
 	}
 =

-	/* Turn on translation and SF (Some machines don't reboot if SF is not se=
t) */
+	/* Turn on translation and SF (Some machines don't reboot if SF is not se=
t, see ReactOS bug #1842) */
 	if (!i8042ChangeMode(DeviceExtension, 0, CCB_TRANSLATE | CCB_SYSTEM_FLAG))
 		return FALSE;
 =

@@ -337,24 +337,12 @@
 =

 static NTSTATUS
 EnableInterrupts(
-	IN PPORT_DEVICE_EXTENSION DeviceExtension)
-{
-	UCHAR FlagsToDisable =3D 0;
-	UCHAR FlagsToEnable =3D 0;
-
+	IN PPORT_DEVICE_EXTENSION DeviceExtension,
+    IN UCHAR FlagsToDisable,
+    IN UCHAR FlagsToEnable)
+{
 	i8042Flush(DeviceExtension);
 =

-	/* Select the devices we have */
-	if (DeviceExtension->Flags & KEYBOARD_PRESENT)
-	{
-		FlagsToDisable |=3D CCB_KBD_DISAB;
-		FlagsToEnable |=3D CCB_KBD_INT_ENAB;
-	}
-	if (DeviceExtension->Flags & MOUSE_PRESENT)
-	{
-		FlagsToDisable |=3D CCB_MOUSE_DISAB;
-		FlagsToEnable |=3D CCB_MOUSE_INT_ENAB;
-	}
 	if (!i8042ChangeMode(DeviceExtension, FlagsToDisable, FlagsToEnable))
 		return STATUS_UNSUCCESSFUL;
 =

@@ -379,6 +367,8 @@
 	IN PPORT_DEVICE_EXTENSION DeviceExtension)
 {
 	NTSTATUS Status;
+    UCHAR FlagsToDisable =3D 0;
+    UCHAR FlagsToEnable =3D 0;
 =

 	if (DeviceExtension->DataPort =3D=3D 0)
 	{
@@ -409,58 +399,40 @@
 	}
 =

 	/* Connect interrupts */
+    Status =3D STATUS_SUCCESS;
+
 	if (DeviceExtension->Flags & KEYBOARD_PRESENT &&
 	    DeviceExtension->Flags & KEYBOARD_CONNECTED &&
 	    DeviceExtension->Flags & KEYBOARD_STARTED &&
-	    !(DeviceExtension->Flags & (MOUSE_PRESENT | KEYBOARD_INITIALIZED)))
-	{
-		/* No mouse, and the keyboard is ready */
+	    !(DeviceExtension->Flags & KEYBOARD_INITIALIZED))
+	{
+		/* Keyboard is ready to be initialized */
 		Status =3D i8042ConnectKeyboardInterrupt(DeviceExtension->KeyboardExtens=
ion);
 		if (NT_SUCCESS(Status))
 		{
 			DeviceExtension->Flags |=3D KEYBOARD_INITIALIZED;
-			Status =3D EnableInterrupts(DeviceExtension);
-		}
-	}
-	else if (DeviceExtension->Flags & MOUSE_PRESENT &&
-	         DeviceExtension->Flags & MOUSE_CONNECTED &&
-	         DeviceExtension->Flags & MOUSE_STARTED &&
-	         !(DeviceExtension->Flags & (KEYBOARD_PRESENT | MOUSE_INITIALIZED=
)))
-	{
-		/* No keyboard, and the mouse is ready */
+            FlagsToDisable |=3D CCB_KBD_DISAB;
+            FlagsToEnable |=3D CCB_KBD_INT_ENAB;
+		}
+	}
+
+	if (DeviceExtension->Flags & MOUSE_PRESENT &&
+	    DeviceExtension->Flags & MOUSE_CONNECTED &&
+	    DeviceExtension->Flags & MOUSE_STARTED &&
+	    !(DeviceExtension->Flags & MOUSE_INITIALIZED))
+	{
+		/* Mouse is ready to be initialized */
 		Status =3D i8042ConnectMouseInterrupt(DeviceExtension->MouseExtension);
 		if (NT_SUCCESS(Status))
 		{
 			DeviceExtension->Flags |=3D MOUSE_INITIALIZED;
-			Status =3D EnableInterrupts(DeviceExtension);
-		}
-	}
-	else if (DeviceExtension->Flags & KEYBOARD_PRESENT &&
-	         DeviceExtension->Flags & KEYBOARD_CONNECTED &&
-	         DeviceExtension->Flags & KEYBOARD_STARTED &&
-	         DeviceExtension->Flags & MOUSE_PRESENT &&
-	         DeviceExtension->Flags & MOUSE_CONNECTED &&
-	         DeviceExtension->Flags & MOUSE_STARTED &&
-	         !(DeviceExtension->Flags & (KEYBOARD_INITIALIZED | MOUSE_INITIAL=
IZED)))
-	{
-		/* The keyboard and mouse are ready */
-		Status =3D i8042ConnectKeyboardInterrupt(DeviceExtension->KeyboardExtens=
ion);
-		if (NT_SUCCESS(Status))
-		{
-			DeviceExtension->Flags |=3D KEYBOARD_INITIALIZED;
-			Status =3D i8042ConnectMouseInterrupt(DeviceExtension->MouseExtension);
-			if (NT_SUCCESS(Status))
-			{
-				DeviceExtension->Flags |=3D MOUSE_INITIALIZED;
-				Status =3D EnableInterrupts(DeviceExtension);
-			}
-		}
-	}
-	else
-	{
-		/* Nothing to do */
-		Status =3D STATUS_SUCCESS;
-	}
+            FlagsToDisable |=3D CCB_MOUSE_DISAB;
+            FlagsToEnable |=3D CCB_MOUSE_INT_ENAB;
+		}
+	}
+
+    if(FlagsToEnable)
+        Status =3D EnableInterrupts(DeviceExtension, FlagsToDisable, Flags=
ToEnable);
 =

 	return Status;
 }




More information about the Ros-diffs mailing list