Author: dgorbachev
Date: Thu Feb 15 13:57:38 2007
New Revision: 25803
URL:
http://svn.reactos.org/svn/reactos?rev=25803&view=rev
Log:
- fix "keyboard does not respond" bug on Biostar board (thanks to Peter
Krawies)
- fix printf()
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
trunk/reactos/boot/freeldr/freeldr/ui/tui.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c Thu Feb 15 13:57:38 2007
@@ -1621,58 +1621,69 @@
{
UCHAR Status;
UCHAR Scancode;
-
+ ULONG Loops;
+ BOOLEAN Result = TRUE;
+
+ /* Identify device */
WRITE_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA,
0xF2);
- StallExecutionProcessor(10000);
-
- Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
- if ((Status & 0x01) != 0x01)
+ /* Wait for reply */
+ for (Loops = 0; Loops < 100; Loops++)
+ {
+ StallExecutionProcessor(10000);
+ Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
+ if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) != 0)
+ break;
+ }
+
+ if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) == 0)
{
/* PC/XT keyboard or no keyboard */
- return FALSE;
+ Result = FALSE;
}
Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
if (Scancode != 0xFA)
{
/* No ACK received */
- return FALSE;
+ Result = FALSE;
}
StallExecutionProcessor(10000);
+
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
- if ((Status & 0x01) != 0x01)
+ if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) == 0)
{
/* Found AT keyboard */
- return TRUE;
+ return Result;
}
Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
if (Scancode != 0xAB)
{
/* No 0xAB received */
- return FALSE;
+ Result = FALSE;
}
StallExecutionProcessor(10000);
+
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
- if ((Status & 0x01) != 0x01)
+ if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) == 0)
{
/* No byte in buffer */
- return FALSE;
+ Result = FALSE;
}
Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
if (Scancode != 0x41)
{
/* No 0x41 received */
- return FALSE;
+ Result = FALSE;
}
/* Found MF-II keyboard */
- return TRUE;
+ return Result;
}
@@ -1880,7 +1891,6 @@
DetectPS2AuxPort(VOID)
{
ULONG Loops;
- UCHAR Scancode;
UCHAR Status;
/* Put the value 0x5A in the output buffer using the
@@ -1901,22 +1911,15 @@
for (Loops = 0; Loops < 10; Loops++)
{
+ StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
-
if ((Status & CONTROLLER_STATUS_OUTPUT_BUFFER_FULL) != 0)
- {
- Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
- if ((Status & CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL) != 0)
- {
- return TRUE;
- }
- break;
- }
-
- StallExecutionProcessor(10000);
- }
-
- return FALSE;
+ break;
+ }
+
+ READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
+
+ return (Status & CONTROLLER_STATUS_MOUSE_OUTPUT_BUFFER_FULL);
}
@@ -1938,7 +1941,7 @@
0xF2);
/* Wait for reply */
- for (Loops = 0; Loops < 10; Loops++)
+ for (Loops = 0; Loops < 100; Loops++)
{
StallExecutionProcessor(10000);
Status = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_STATUS);
@@ -1963,15 +1966,6 @@
Scancode = READ_PORT_UCHAR((PUCHAR)CONTROLLER_REGISTER_DATA);
if (Scancode != 0x00)
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;
}
Modified: trunk/reactos/boot/freeldr/freeldr/ui/tui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/ui/tu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/ui/tui.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/ui/tui.c Thu Feb 15 13:57:38 2007
@@ -45,9 +45,9 @@
{
case 'd': case 'u': case 'x':
if (c == 'x')
- *_itoa(va_arg(ap, unsigned long), str, 16) = 0;
+ _itoa(va_arg(ap, unsigned long), str, 16);
else
- *_itoa(va_arg(ap, unsigned long), str, 10) = 0;
+ _itoa(va_arg(ap, unsigned long), str, 10);
ptr = str;