Modified: trunk/reactos/drivers/input/i8042prt/i8042prt.c
Modified: trunk/reactos/drivers/input/i8042prt/i8042prt.h
Modified: trunk/reactos/drivers/input/i8042prt/keyboard.c
Modified: trunk/reactos/drivers/input/i8042prt/mouse.c
Modified: trunk/reactos/drivers/input/i8042prt/registry.c
--- trunk/reactos/drivers/input/i8042prt/i8042prt.c 2005-08-05 10:31:28 UTC (rev 17068)
+++ trunk/reactos/drivers/input/i8042prt/i8042prt.c 2005-08-05 10:35:32 UTC (rev 17069)
@@ -153,7 +153,7 @@
if (WaitForAck) {
Status = I8042ReadDataWait(DevExt, &Ack);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
return Status;
if (Ack == KBD_ACK)
return STATUS_SUCCESS;
@@ -426,7 +426,7 @@
I8042SynchReadPort,
I8042SynchWritePortKbd,
FALSE);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
WorkItemData->Irp->IoStatus.Status = Status;
goto hookworkitemdone;
}
@@ -514,8 +514,14 @@
UCHAR Value = 0;
UINT Counter;
+ DevExt->MouseExists = FALSE;
+ DevExt->KeyboardExists = FALSE;
+
I8042Flush();
+ if (!I8042Write(DevExt, I8042_DATA_PORT, 0x74))
+ return STATUS_TIMEOUT;
+
if (!I8042Write(DevExt, I8042_CTRL_PORT, KBD_SELF_TEST))
return STATUS_TIMEOUT;
@@ -525,37 +531,26 @@
Status = I8042ReadDataWait(DevExt, &Value);
} while ((Counter--) && (STATUS_TIMEOUT == Status));
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
return Status;
if (Value != 0x55) {
DPRINT1("Got %x instead of 55\n", Value);
return STATUS_IO_DEVICE_ERROR;
}
- if (!I8042Write(DevExt, I8042_CTRL_PORT, KBD_LINE_TEST))
- return STATUS_TIMEOUT;
- Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS)
- return Status;
-
- if (Value == 0) {
- DevExt->KeyboardExists = TRUE;
- } else {
- DevExt->KeyboardExists = FALSE;
+ if (I8042Write(DevExt, I8042_CTRL_PORT, KBD_LINE_TEST))
+ {
+ Status = I8042ReadDataWait(DevExt, &Value);
+ if (NT_SUCCESS(Status) && Value == 0)
+ DevExt->KeyboardExists = TRUE;
}
- if (!I8042Write(DevExt, I8042_CTRL_PORT, MOUSE_LINE_TEST))
- return STATUS_TIMEOUT;
-
- Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS)
- return Status;
-
- if (Value == 0) {
- DevExt->MouseExists = TRUE;
- } else {
- DevExt->MouseExists = FALSE;
+ if (I8042Write(DevExt, I8042_CTRL_PORT, MOUSE_LINE_TEST))
+ {
+ Status = I8042ReadDataWait(DevExt, &Value);
+ if (NT_SUCCESS(Status) && Value == 0)
+ DevExt->MouseExists = TRUE;
}
return STATUS_SUCCESS;
@@ -566,28 +561,36 @@
NTSTATUS Status;
Status = I8042BasicDetect(DevExt);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("Basic keyboard detection failed: %x\n", Status);
return Status;
}
if (!DevExt->KeyboardExists) {
- DPRINT("Keyboard not detected\n");
+ DPRINT("Keyboard port not detected\n");
if (DevExt->Settings.Headless)
/* Act as if it exists regardless */
DevExt->KeyboardExists = TRUE;
} else {
- DPRINT("Keyboard detected\n");
+ DPRINT("Keyboard port detected\n");
DevExt->KeyboardExists = I8042DetectKeyboard(DevExt);
}
+ if (DevExt->MouseExists) {
+ DPRINT("Mouse port detected\n");
+ DevExt->MouseExists = I8042DetectMouse(DevExt);
+ }
+
if (DevExt->KeyboardExists) {
+ DPRINT("Keyboard detected\n");
I8042KeyboardEnable(DevExt);
I8042KeyboardEnableInterrupt(DevExt);
}
- if (DevExt->MouseExists)
+ if (DevExt->MouseExists) {
+ DPRINT("Mouse detected\n");
I8042MouseEnable(DevExt);
+ }
return STATUS_SUCCESS;
}
--- trunk/reactos/drivers/input/i8042prt/i8042prt.h 2005-08-05 10:31:28 UTC (rev 17068)
+++ trunk/reactos/drivers/input/i8042prt/i8042prt.h 2005-08-05 10:35:32 UTC (rev 17069)
@@ -387,6 +387,8 @@
BOOLEAN STDCALL I8042MouseEnable(PDEVICE_EXTENSION DevExt);
BOOLEAN STDCALL I8042MouseDisable(PDEVICE_EXTENSION DevExt);
+BOOLEAN STDCALL I8042DetectMouse(PDEVICE_EXTENSION DevExt);
+
/* ps2pp.c */
VOID I8042MouseHandlePs2pp(PDEVICE_EXTENSION DevExt, BYTE Input);
--- trunk/reactos/drivers/input/i8042prt/keyboard.c 2005-08-05 10:31:28 UTC (rev 17068)
+++ trunk/reactos/drivers/input/i8042prt/keyboard.c 2005-08-05 10:35:32 UTC (rev 17069)
@@ -605,7 +605,7 @@
}
Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("No response after read i8042 mode\n");
return FALSE;
}
@@ -640,13 +640,13 @@
Status = I8042SynchWritePort(DevExt, 0, KBD_GET_ID, TRUE);
} while (STATUS_TIMEOUT == Status && RetryCount--);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("Can't write GET_ID (%x)\n", Status);
return FALSE;
}
Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("No response after GET_ID\n");
/* Could be an AT keyboard */
DevExt->KeyboardIsAT = TRUE;
@@ -663,7 +663,7 @@
DPRINT("Keyboard ID: %x", Value);
Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT("Partial ID\n");
return FALSE;
}
@@ -672,12 +672,12 @@
detectsetleds:
Status = I8042SynchWritePort(DevExt, 0, KBD_SET_LEDS, TRUE);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT("Can't write SET_LEDS (%x)\n", Status);
return FALSE;
}
Status = I8042SynchWritePort(DevExt, 0, 0, TRUE);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT("Can't finish SET_LEDS (%x)\n", Status);
return FALSE;
}
@@ -690,7 +690,7 @@
}
Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("No response after read i8042 mode\n");
return FALSE;
}
--- trunk/reactos/drivers/input/i8042prt/mouse.c 2005-08-05 10:31:28 UTC (rev 17068)
+++ trunk/reactos/drivers/input/i8042prt/mouse.c 2005-08-05 10:35:32 UTC (rev 17069)
@@ -833,7 +833,7 @@
}
Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("No response after read i8042 mode\n");
return FALSE;
}
@@ -869,7 +869,7 @@
}
Status = I8042ReadDataWait(DevExt, &Value);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1("No response after read i8042 mode\n");
return FALSE;
}
@@ -895,3 +895,45 @@
return TRUE;
}
+
+BOOLEAN STDCALL I8042DetectMouse(PDEVICE_EXTENSION DevExt)
+{
+ NTSTATUS Status;
+ UCHAR Value;
+ UINT RetryCount = 10;
+
+ DPRINT("Detecting mouse\n");
+
+ I8042MouseDisable(DevExt);
+
+ do {
+ Status = I8042SynchWritePortMouse(DevExt, KBD_GET_ID, TRUE);
+ } while (STATUS_TIMEOUT == Status && RetryCount--);
+
+ if (!NT_SUCCESS(Status)) {
+ DPRINT1("Can't write AUX_GET_ID (%x)\n", Status);
+ return FALSE;
+ }
+
+ Status = I8042ReadDataWait(DevExt, &Value);
+ if (!NT_SUCCESS(Status)) {
+ DPRINT1("No response after AUX_GET_ID\n");
+ return FALSE;
+ }
+
+ if (Value != 0xFA) {
+ DPRINT("Bad ID: %x\n", Value);
+ return FALSE;
+ }
+
+ Status = I8042ReadDataWait(DevExt, &Value);
+ if (!NT_SUCCESS(Status)) {
+ DPRINT("Partial ID\n");
+ return FALSE;
+ }
+
+ DPRINT ("%x\n", Value);
+
+ return TRUE;
+}
+
--- trunk/reactos/drivers/input/i8042prt/registry.c 2005-08-05 10:31:28 UTC (rev 17068)
+++ trunk/reactos/drivers/input/i8042prt/registry.c 2005-08-05 10:35:32 UTC (rev 17069)
@@ -211,7 +211,7 @@
NULL,
NULL);
- if (Status != STATUS_SUCCESS) {
+ if (!NT_SUCCESS(Status)) {
DPRINT1 ("Can't read registry: %x\n", Status);
/* Actually, the defaults are not set when the function
* fails, as would happen during setup, so you have to