Author: fireball
Date: Thu May 24 01:26:24 2007
New Revision: 26875
URL:
http://svn.reactos.org/svn/reactos?rev=26875&view=rev
Log:
- Merge Revision: 25668
Author: dgorbachev
Date: 11:04:23, 1 February 2007.
Message:
Commit attachment #1151
----
Modified : /trunk/reactos/boot/freeldr/freeldr/inifile/inifile.c
- Merge Revision: 25745
Author: dgorbachev
Date: 3:29:50, 7 February 2007.
Message:
Fix "keyboard does not respond" bug. Thanks to Peter Krawies (breakoutbox /AT/
web /DOT/ de)
----
Modified : /trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
Modified:
branches/winldr/arch/i386/hardware.c
branches/winldr/inifile/inifile.c
Modified: branches/winldr/arch/i386/hardware.c
URL:
http://svn.reactos.org/svn/reactos/branches/winldr/arch/i386/hardware.c?rev…
==============================================================================
--- branches/winldr/arch/i386/hardware.c (original)
+++ branches/winldr/arch/i386/hardware.c Thu May 24 01:26:24 2007
@@ -1955,6 +1955,8 @@
{
UCHAR Scancode;
UCHAR Status;
+ ULONG Loops;
+ BOOLEAN Result = TRUE;
PS2ControllerWait();
WRITE_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_CONTROL,
@@ -1965,31 +1967,43 @@
WRITE_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA,
0xF2);
- StallExecutionProcessor(10000);
+ /* Wait for reply */
+ for (Loops = 0; Loops < 10; Loops++)
+ {
+ StallExecutionProcessor(10000);
+ Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
+ if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) != 0)
+ break;
+ }
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL) == 0)
- {
- return FALSE;
- }
+ Result = FALSE;
Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
if (Scancode != 0xFA)
- return FALSE;
+ Result = FALSE;
StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
if ((Status & CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL) == 0)
- {
- return FALSE;
- }
+ Result = FALSE;
Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
if (Scancode != 0x00)
- return FALSE;
-
- return TRUE;
+ Result = FALSE;
+
+ /* Flush output buffer */
+ for (Loops = 0; Loops < 10; Loops++)
+ {
+ Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
+ if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) == 0)
+ break;
+ StallExecutionProcessor(10000);
+ }
+
+ return Result;
}
static VOID
Modified: branches/winldr/inifile/inifile.c
URL:
http://svn.reactos.org/svn/reactos/branches/winldr/inifile/inifile.c?rev=26…
==============================================================================
--- branches/winldr/inifile/inifile.c (original)
+++ branches/winldr/inifile/inifile.c Thu May 24 01:26:24 2007
@@ -104,12 +104,12 @@
DbgPrint((DPRINT_INIFILE, "IniReadSettingByNumber() Setting value = %s\n",
SectionItem->ItemValue));
DbgPrint((DPRINT_INIFILE, "1 NameSize = %d ValueSize = %d\n", NameSize,
ValueSize));
- RtlZeroMemory(SettingName, NameSize);
- RtlZeroMemory(SettingValue, ValueSize);
DbgPrint((DPRINT_INIFILE, "2 NameSize = %d ValueSize = %d\n", NameSize,
ValueSize));
- strncpy(SettingName, SectionItem->ItemName, NameSize);
+ strncpy(SettingName, SectionItem->ItemName, NameSize - 1);
+ SettingName[NameSize - 1] = '\0';
DbgPrint((DPRINT_INIFILE, "3 NameSize = %d ValueSize = %d\n", NameSize,
ValueSize));
- strncpy(SettingValue, SectionItem->ItemValue, ValueSize);
+ strncpy(SettingValue, SectionItem->ItemValue, ValueSize - 1);
+ SettingValue[ValueSize - 1] = '\0';
DbgPrint((DPRINT_INIFILE, "4 NameSize = %d ValueSize = %d\n", NameSize,
ValueSize));
DbgDumpBuffer(DPRINT_INIFILE, SettingName, NameSize);
DbgDumpBuffer(DPRINT_INIFILE, SettingValue, ValueSize);
@@ -146,8 +146,8 @@
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting \'%s\'
found.\n", SettingName));
DbgPrint((DPRINT_INIFILE, "IniReadSettingByName() Setting value = %s\n",
SectionItem->ItemValue));
- RtlZeroMemory(Buffer, BufferSize);
- strncpy(Buffer, SectionItem->ItemValue, BufferSize);
+ strncpy(Buffer, SectionItem->ItemValue, BufferSize - 1);
+ Buffer[BufferSize - 1] = '\0';
return TRUE;
}