ReadFile should return 0 to lpNumberOfBytesRead if NtReadFile returned
STATUS_END_OF_FILE for synchronous operations
Modified: trunk/reactos/lib/kernel32/file/rw.c
_____
Modified: trunk/reactos/lib/kernel32/file/rw.c
--- trunk/reactos/lib/kernel32/file/rw.c 2005-05-06 22:55:52 UTC
(rev 15066)
+++ trunk/reactos/lib/kernel32/file/rw.c 2005-05-07 00:21:06 UTC
(rev 15067)
@@ -221,7 +221,7 @@
/* lpNumberOfBytesRead must not be NULL here, in fact Win
doesn't
check that case either and crashes (only after the
operation
completed) */
- *lpNumberOfBytesRead = Iosb.Information;
+ *lpNumberOfBytesRead = 0;
return TRUE;
}
Patch by tinus: Resolves issue of keyboard detection when e.g. booting
ReactOS under VMWare with no keyboard grabbed.
Modified: trunk/reactos/drivers/input/i8042prt/keyboard.c
_____
Modified: trunk/reactos/drivers/input/i8042prt/keyboard.c
--- trunk/reactos/drivers/input/i8042prt/keyboard.c 2005-05-06
20:45:30 UTC (rev 15061)
+++ trunk/reactos/drivers/input/i8042prt/keyboard.c 2005-05-06
21:18:20 UTC (rev 15062)
@@ -551,6 +551,26 @@
return Irp->IoStatus.Status;
}
+/* This is all pretty confusing. There's more than one way to
+ * disable/enable the keyboard. You can send KBD_ENABLE to the
+ * keyboard, and it will start scanning keys. Sending KBD_DISABLE
+ * will disable the key scanning but also reset the parameters to
+ * defaults.
+ *
+ * You can also send 0xAE to the controller for enabling the
+ * keyboard clock line and 0xAD for disabling it. Then it'll
+ * automatically get turned on at the next command. The last
+ * way is by modifying the bit that drives the clock line in the
+ * 'command byte' of the controller. This is almost, but not quite,
+ * the same as the AE/AD thing. The difference can be used to detect
+ * some really old broken keyboard controllers which I hope won't be
+ * necessary.
+ *
+ * Anyway, disabling the keyboard helps the detection and it also
+ * clears the keyboard buffer and sets defaults which is what we
+ * want.
+ */
+
BOOLEAN STDCALL I8042KeyboardEnable(PDEVICE_EXTENSION DevExt)
{
DPRINT("Enabling keyboard\n");
@@ -564,6 +584,19 @@
return TRUE;
}
+BOOLEAN STDCALL I8042KeyboardDefaultsAndDisable(PDEVICE_EXTENSION
DevExt)
+{
+ DPRINT("Disabling keyboard\n");
+ if (STATUS_SUCCESS != I8042SynchWritePort(DevExt,
+ 0,
+ KBD_DISABLE,
+ TRUE)) {
+ DPRINT("Can't disable keyboard\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
BOOLEAN STDCALL I8042KeyboardEnableInterrupt(PDEVICE_EXTENSION DevExt)
{
UCHAR Value;
@@ -606,12 +639,14 @@
DPRINT("Detecting keyboard\n");
+ I8042KeyboardDefaultsAndDisable(DevExt);
+
do {
Status = I8042SynchWritePort(DevExt, 0, KBD_GET_ID,
TRUE);
} while (STATUS_TIMEOUT == Status && RetryCount--);
if (Status != STATUS_SUCCESS) {
- DPRINT("Can't write GET_ID (%x)\n", Status);
+ DPRINT1("Can't write GET_ID (%x)\n", Status);
return FALSE;
}
HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt\Parameters","SampleRate
",0x00010001,0x00000060
60 are the dec value but it have not be convort to hex that is 0x3c
legmet value are, e.g., 10, 20, 40, 60, 80, 100, 200.'
in dec in hex 0x0a, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8
Modified: trunk/reactos/bootdata/hivesys.inf
_____
Modified: trunk/reactos/bootdata/hivesys.inf
--- trunk/reactos/bootdata/hivesys.inf 2005-05-06 19:42:39 UTC (rev
15059)
+++ trunk/reactos/bootdata/hivesys.inf 2005-05-06 20:12:37 UTC (rev
15060)
@@ -581,7 +581,7 @@
HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt","Start",0x00010001,0x0
0000001
HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt","Type",0x00010001,0x00
000001
-HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt\Parameters","SampleRat
e",0x00010001,0x00000060
+HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt\Parameters","SampleRat
e",0x00010001,0x0000003c
HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt\Parameters","BreakOnSys
Rq",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\i8042Prt\Parameters","MouseResol
ution",0x00010001,0x00000003