mirror of
https://github.com/reactos/reactos.git
synced 2024-08-19 18:02:55 +00:00
Fix keyboard and mouse detection. We must disable the controller features before beginning the port check and we shouldn't fail if some port isn't found. Also detect the mouse on port before trying to use it.
svn path=/trunk/; revision=17069
This commit is contained in:
parent
d974b427de
commit
457bfd725b
|
@ -153,7 +153,7 @@ NTSTATUS STDCALL I8042SynchWritePort(PDEVICE_EXTENSION DevExt,
|
|||
|
||||
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 @@ VOID STDCALL I8042SendHookWorkItem(PDEVICE_OBJECT DeviceObject,
|
|||
I8042SynchReadPort,
|
||||
I8042SynchWritePortKbd,
|
||||
FALSE);
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
WorkItemData->Irp->IoStatus.Status = Status;
|
||||
goto hookworkitemdone;
|
||||
}
|
||||
|
@ -514,8 +514,14 @@ static NTSTATUS STDCALL I8042BasicDetect(PDEVICE_EXTENSION DevExt)
|
|||
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 @@ static NTSTATUS STDCALL I8042BasicDetect(PDEVICE_EXTENSION DevExt)
|
|||
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 @@ static NTSTATUS STDCALL I8042Initialize(PDEVICE_EXTENSION DevExt)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -387,6 +387,8 @@ VOID STDCALL I8042MouseHandle(PDEVICE_EXTENSION DevExt,
|
|||
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);
|
||||
|
||||
|
|
|
@ -605,7 +605,7 @@ BOOLEAN STDCALL I8042KeyboardEnableInterrupt(PDEVICE_EXTENSION DevExt)
|
|||
}
|
||||
|
||||
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 @@ BOOLEAN STDCALL I8042DetectKeyboard(PDEVICE_EXTENSION DevExt)
|
|||
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 @@ BOOLEAN STDCALL I8042DetectKeyboard(PDEVICE_EXTENSION DevExt)
|
|||
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 @@ BOOLEAN STDCALL I8042DetectKeyboard(PDEVICE_EXTENSION DevExt)
|
|||
|
||||
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 @@ detectsetleds:
|
|||
}
|
||||
|
||||
Status = I8042ReadDataWait(DevExt, &Value);
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
if (!NT_SUCCESS(Status)) {
|
||||
DPRINT1("No response after read i8042 mode\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -833,7 +833,7 @@ BOOLEAN STDCALL I8042MouseEnable(PDEVICE_EXTENSION DevExt)
|
|||
}
|
||||
|
||||
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 @@ BOOLEAN STDCALL I8042MouseDisable(PDEVICE_EXTENSION DevExt)
|
|||
}
|
||||
|
||||
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 @@ BOOLEAN STDCALL I8042MouseDisable(PDEVICE_EXTENSION DevExt)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ VOID STDCALL I8042ReadRegistry(PDRIVER_OBJECT DriverObject,
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue