[ros-diffs] [fireball] 32153: - Make i8042Flush flush both output and input buffers. - Make i8042Flush apply only KBD_OBF flag (applying MOU_OBF leads to an infinite loop trying to flush the buffer). - Fix a bug in i8042Write, where instead of waiting by polling a PollingIterations times (~10000), it was using ResendIterations (=3), thus giving 8042 very small chance of processing the data. - Make i8042BasicDetect resend CTRL_SELF_TEST sequence, if controller asks so. Maximum resend iterations are limited by ResendIterations variable. - Reinsert debug-messages hack, since this is an early-loading driver, and it's not possible to break in to KDBG to change debug filter values. - As a result, keyboard and mouse work on real hardware again. See issue #3036 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Wed Feb 6 10:46:38 CET 2008


Author: fireball
Date: Wed Feb  6 12:46:38 2008
New Revision: 32153

URL: http://svn.reactos.org/svn/reactos?rev=32153&view=rev
Log:
- Make i8042Flush flush both output and input buffers.
- Make i8042Flush apply only KBD_OBF flag (applying MOU_OBF leads to an infinite loop trying to flush the buffer).
- Fix a bug in i8042Write, where instead of waiting by polling a PollingIterations times (~10000), it was using ResendIterations (=3), thus giving 8042 very small chance of processing the data.
- Make i8042BasicDetect resend CTRL_SELF_TEST sequence, if controller asks so. Maximum resend iterations are limited by ResendIterations variable.
- Reinsert debug-messages hack, since this is an early-loading driver, and it's not possible to break in to KDBG to change debug filter values.
- As a result, keyboard and mouse work on real hardware again.
See issue #3036 for more details.

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

Modified: trunk/reactos/drivers/input/i8042prt/i8042prt.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042prt/i8042prt.c?rev=32153&r1=32152&r2=32153&view=diff
==============================================================================
--- trunk/reactos/drivers/input/i8042prt/i8042prt.c (original)
+++ trunk/reactos/drivers/input/i8042prt/i8042prt.c Wed Feb  6 12:46:38 2008
@@ -475,6 +475,17 @@
 	ULONG i;
 	NTSTATUS Status;
 
+	/* ROS Hack: ideally, we shouldn't have to initialize debug level this way,
+	   but since the only way is to change it via KDBG, it's better to leave
+	   it here too. */
+#if 0
+	DbgSetDebugFilterState(
+		DPFLTR_I8042PRT_ID,
+		(1 << DPFLTR_ERROR_LEVEL) | (1 << DPFLTR_WARNING_LEVEL) |
+		(1 << DPFLTR_TRACE_LEVEL) /*| (1 << DPFLTR_INFO_LEVEL)*/ | DPFLTR_MASK,
+		TRUE);
+#endif
+
 	Status = IoAllocateDriverObjectExtension(
 		DriverObject,
 		DriverObject,

Modified: trunk/reactos/drivers/input/i8042prt/pnp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042prt/pnp.c?rev=32153&r1=32152&r2=32153&view=diff
==============================================================================
--- trunk/reactos/drivers/input/i8042prt/pnp.c (original)
+++ trunk/reactos/drivers/input/i8042prt/pnp.c Wed Feb  6 12:46:38 2008
@@ -75,6 +75,7 @@
 	IN PPORT_DEVICE_EXTENSION DeviceExtension)
 {
 	NTSTATUS Status;
+	ULONG ResendIterations;
 	UCHAR Value = 0;
 
 	/* Don't enable keyboard and mouse interrupts, disable keyboard/mouse */
@@ -83,23 +84,33 @@
 
 	i8042Flush(DeviceExtension);
 
-	if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, CTRL_SELF_TEST))
-	{
-		WARN_(I8042PRT, "Writing CTRL_SELF_TEST command failed\n");
-		return STATUS_IO_TIMEOUT;
-	}
-
-	Status = i8042ReadDataWait(DeviceExtension, &Value);
-	if (!NT_SUCCESS(Status))
-	{
-		WARN_(I8042PRT, "Failed to read CTRL_SELF_TEST response, status 0x%08lx\n", Status);
-		return Status;
-	}
-
-	if (Value != 0x55)
-	{
-		WARN_(I8042PRT, "Got 0x%02x instead of 0x55\n", Value);
-		return STATUS_IO_DEVICE_ERROR;
+	ResendIterations = DeviceExtension->Settings.ResendIterations + 1;
+	while (ResendIterations--)
+	{
+		if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, CTRL_SELF_TEST))
+		{
+			WARN_(I8042PRT, "Writing CTRL_SELF_TEST command failed\n");
+			return STATUS_IO_TIMEOUT;
+		}
+
+		Status = i8042ReadDataWait(DeviceExtension, &Value);
+		if (!NT_SUCCESS(Status))
+		{
+			WARN_(I8042PRT, "Failed to read CTRL_SELF_TEST response, status 0x%08lx\n", Status);
+			return Status;
+		}
+
+		if (Value == KBD_RESEND)
+		{
+			TRACE_(I8042PRT, "Resending...\n", Value);
+			KeStallExecutionProcessor(50);
+			continue;
+		}
+		else if (Value != 0x55)
+		{
+			WARN_(I8042PRT, "Got 0x%02x instead of 0x55\n", Value);
+			return STATUS_IO_DEVICE_ERROR;
+		}
 	}
 
 	/*

Modified: trunk/reactos/drivers/input/i8042prt/readwrite.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042prt/readwrite.c?rev=32153&r1=32152&r2=32153&view=diff
==============================================================================
--- trunk/reactos/drivers/input/i8042prt/readwrite.c (original)
+++ trunk/reactos/drivers/input/i8042prt/readwrite.c Wed Feb  6 12:46:38 2008
@@ -21,8 +21,16 @@
 {
 	UCHAR Ignore;
 
-	while (NT_SUCCESS(i8042ReadData(DeviceExtension, KBD_OBF | MOU_OBF, &Ignore))) {
-		INFO_(I8042PRT, "Data flushed\n"); /* drop */
+	/* Flush output buffer */
+	while (NT_SUCCESS(i8042ReadData(DeviceExtension, KBD_OBF /* | MOU_OBF*/, &Ignore))) {
+		KeStallExecutionProcessor(50);
+		TRACE_(I8042PRT, "Output data flushed\n");
+	}
+
+	/* Flush input buffer */
+	while (NT_SUCCESS(i8042ReadData(DeviceExtension, KBD_IBF, &Ignore))) {
+		KeStallExecutionProcessor(50);
+		TRACE_(I8042PRT, "Input data flushed\n");
 	}
 }
 
@@ -189,20 +197,20 @@
 	IN PUCHAR addr,
 	IN UCHAR data)
 {
-	ULONG ResendIterations;
+	ULONG Counter;
 
 	ASSERT(addr);
 	ASSERT(DeviceExtension->ControlPort != NULL);
 
-	ResendIterations = DeviceExtension->Settings.ResendIterations;
+	Counter = DeviceExtension->Settings.PollingIterations;
 
 	while ((KBD_IBF & READ_PORT_UCHAR(DeviceExtension->ControlPort)) &&
-	       (ResendIterations--))
-	{
-		KeStallExecutionProcessor(50);
-	}
-
-	if (ResendIterations)
+	       (Counter--))
+	{
+		KeStallExecutionProcessor(50);
+	}
+
+	if (Counter)
 	{
 		WRITE_PORT_UCHAR(addr, data);
 		INFO_(I8042PRT, "Sent 0x%x to port %p\n", data, addr);




More information about the Ros-diffs mailing list