mirror of
https://github.com/reactos/reactos.git
synced 2025-07-22 12:53:47 +00:00
- 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. svn path=/trunk/; revision=32153
This commit is contained in:
parent
75172afb72
commit
dbc44341a9
3 changed files with 50 additions and 20 deletions
|
@ -475,6 +475,17 @@ DriverEntry(
|
||||||
ULONG i;
|
ULONG i;
|
||||||
NTSTATUS Status;
|
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(
|
Status = IoAllocateDriverObjectExtension(
|
||||||
DriverObject,
|
DriverObject,
|
||||||
DriverObject,
|
DriverObject,
|
||||||
|
|
|
@ -75,6 +75,7 @@ i8042BasicDetect(
|
||||||
IN PPORT_DEVICE_EXTENSION DeviceExtension)
|
IN PPORT_DEVICE_EXTENSION DeviceExtension)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
ULONG ResendIterations;
|
||||||
UCHAR Value = 0;
|
UCHAR Value = 0;
|
||||||
|
|
||||||
/* Don't enable keyboard and mouse interrupts, disable keyboard/mouse */
|
/* Don't enable keyboard and mouse interrupts, disable keyboard/mouse */
|
||||||
|
@ -83,23 +84,33 @@ i8042BasicDetect(
|
||||||
|
|
||||||
i8042Flush(DeviceExtension);
|
i8042Flush(DeviceExtension);
|
||||||
|
|
||||||
if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, CTRL_SELF_TEST))
|
ResendIterations = DeviceExtension->Settings.ResendIterations + 1;
|
||||||
|
while (ResendIterations--)
|
||||||
{
|
{
|
||||||
WARN_(I8042PRT, "Writing CTRL_SELF_TEST command failed\n");
|
if (!i8042Write(DeviceExtension, DeviceExtension->ControlPort, CTRL_SELF_TEST))
|
||||||
return STATUS_IO_TIMEOUT;
|
{
|
||||||
}
|
WARN_(I8042PRT, "Writing CTRL_SELF_TEST command failed\n");
|
||||||
|
return STATUS_IO_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
Status = i8042ReadDataWait(DeviceExtension, &Value);
|
Status = i8042ReadDataWait(DeviceExtension, &Value);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
WARN_(I8042PRT, "Failed to read CTRL_SELF_TEST response, status 0x%08lx\n", Status);
|
WARN_(I8042PRT, "Failed to read CTRL_SELF_TEST response, status 0x%08lx\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Value != 0x55)
|
if (Value == KBD_RESEND)
|
||||||
{
|
{
|
||||||
WARN_(I8042PRT, "Got 0x%02x instead of 0x55\n", Value);
|
TRACE_(I8042PRT, "Resending...\n", Value);
|
||||||
return STATUS_IO_DEVICE_ERROR;
|
KeStallExecutionProcessor(50);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (Value != 0x55)
|
||||||
|
{
|
||||||
|
WARN_(I8042PRT, "Got 0x%02x instead of 0x55\n", Value);
|
||||||
|
return STATUS_IO_DEVICE_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,8 +21,16 @@ i8042Flush(
|
||||||
{
|
{
|
||||||
UCHAR Ignore;
|
UCHAR Ignore;
|
||||||
|
|
||||||
while (NT_SUCCESS(i8042ReadData(DeviceExtension, KBD_OBF | MOU_OBF, &Ignore))) {
|
/* Flush output buffer */
|
||||||
INFO_(I8042PRT, "Data flushed\n"); /* drop */
|
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 @@ i8042Write(
|
||||||
IN PUCHAR addr,
|
IN PUCHAR addr,
|
||||||
IN UCHAR data)
|
IN UCHAR data)
|
||||||
{
|
{
|
||||||
ULONG ResendIterations;
|
ULONG Counter;
|
||||||
|
|
||||||
ASSERT(addr);
|
ASSERT(addr);
|
||||||
ASSERT(DeviceExtension->ControlPort != NULL);
|
ASSERT(DeviceExtension->ControlPort != NULL);
|
||||||
|
|
||||||
ResendIterations = DeviceExtension->Settings.ResendIterations;
|
Counter = DeviceExtension->Settings.PollingIterations;
|
||||||
|
|
||||||
while ((KBD_IBF & READ_PORT_UCHAR(DeviceExtension->ControlPort)) &&
|
while ((KBD_IBF & READ_PORT_UCHAR(DeviceExtension->ControlPort)) &&
|
||||||
(ResendIterations--))
|
(Counter--))
|
||||||
{
|
{
|
||||||
KeStallExecutionProcessor(50);
|
KeStallExecutionProcessor(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ResendIterations)
|
if (Counter)
|
||||||
{
|
{
|
||||||
WRITE_PORT_UCHAR(addr, data);
|
WRITE_PORT_UCHAR(addr, data);
|
||||||
INFO_(I8042PRT, "Sent 0x%x to port %p\n", data, addr);
|
INFO_(I8042PRT, "Sent 0x%x to port %p\n", data, addr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue