Hopefully fix some input problems. If input does not work for you please let me know.

svn path=/trunk/; revision=13845
This commit is contained in:
Gregor Anich 2005-03-06 02:06:11 +00:00
parent 088d3f0612
commit 3aa3b694b0
4 changed files with 47 additions and 27 deletions

View file

@ -272,10 +272,15 @@ KdbProfileInterrupt(ULONG_PTR Eip);
#define KdbpSafeReadMemory(dst, src, size) MmSafeCopyFromUser(dst, src, size) #define KdbpSafeReadMemory(dst, src, size) MmSafeCopyFromUser(dst, src, size)
#define KdbpSafeWriteMemory(dst, src, size) MmSafeCopyToUser(dst, src, size) #define KdbpSafeWriteMemory(dst, src, size) MmSafeCopyToUser(dst, src, size)
#define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard(ScanCode, 0)
CHAR CHAR
KdbpTryGetCharKeyboard(PULONG ScanCode); KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry);
ULONG
KdbpTryGetCharSerial(VOID); #define KdbpGetCharSerial() KdbpTryGetCharSerial(0)
CHAR
KdbpTryGetCharSerial(UINT Retry);
VOID VOID
KdbEnter(VOID); KdbEnter(VOID);
VOID VOID

View file

@ -1682,6 +1682,7 @@ KdbpPrint(
INT Length; INT Length;
INT i; INT i;
INT RowsPrintedByTerminal; INT RowsPrintedByTerminal;
ULONG ScanCode;
va_list ap; va_list ap;
/* Check if the user has aborted output of the current command */ /* Check if the user has aborted output of the current command */
@ -1703,20 +1704,17 @@ KdbpPrint(
{ {
/* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
TerminalReportsSize = FALSE; TerminalReportsSize = FALSE;
DbgPrint("\x1b[18t"); //DbgPrint("\x1b[18t");
i = 10; c = KdbpTryGetCharSerial(10);
while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
if (c == KEY_ESC) if (c == KEY_ESC)
{ {
i = 5; c = KdbpTryGetCharSerial(5);
while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
if (c == '[') if (c == '[')
{ {
Length = 0; Length = 0;
for (;;) for (;;)
{ {
i = 5; c = KdbpTryGetCharSerial(5);
while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1));
if (c == -1) if (c == -1)
break; break;
Buffer[Length++] = c; Buffer[Length++] = c;
@ -1781,13 +1779,19 @@ KdbpPrint(
if (KdbNumberOfColsPrinted > 0) if (KdbNumberOfColsPrinted > 0)
DbgPrint("\n"); DbgPrint("\n");
DbgPrint("--- Press q to abort, any other key to continue ---"); DbgPrint("--- Press q to abort, any other key to continue ---");
while ((c = KdbpTryGetCharSerial()) == -1); if (KdDebugState & KD_DEBUG_KDSERIAL)
c = KdbpGetCharSerial();
else
c = KdbpGetCharKeyboard(&ScanCode);
if (c == '\r') if (c == '\r')
{ {
/* Ignore \r and wait for \n or another \r - if \n is not received here /* Try to read '\n' which might follow '\r' - if \n is not received here
* it will be interpreted as "return" when the next command should be read. * it will be interpreted as "return" when the next command should be read.
*/ */
while ((c = KdbpTryGetCharSerial()) == -1); if (KdDebugState & KD_DEBUG_KDSERIAL)
c = KdbpTryGetCharSerial(5);
else
c = KdbpTryGetCharKeyboard(&ScanCode, 5);
} }
DbgPrint("\n"); DbgPrint("\n");
if (c == 'q') if (c == 'q')
@ -1914,7 +1918,7 @@ KdbpReadCommand(
OUT PCHAR Buffer, OUT PCHAR Buffer,
IN ULONG Size) IN ULONG Size)
{ {
CHAR Key; CHAR Key, NextKey;
PCHAR Orig = Buffer; PCHAR Orig = Buffer;
ULONG ScanCode = 0; ULONG ScanCode = 0;
BOOLEAN EchoOn; BOOLEAN EchoOn;
@ -1929,14 +1933,14 @@ KdbpReadCommand(
{ {
if (KdDebugState & KD_DEBUG_KDSERIAL) if (KdDebugState & KD_DEBUG_KDSERIAL)
{ {
while ((Key = KdbpTryGetCharSerial()) == -1); Key = KdbpGetCharSerial();
ScanCode = 0; ScanCode = 0;
if (Key == KEY_ESC) /* ESC */ if (Key == KEY_ESC) /* ESC */
{ {
while ((Key = KdbpTryGetCharSerial()) == -1); Key = KdbpGetCharSerial();
if (Key == '[') if (Key == '[')
{ {
while ((Key = KdbpTryGetCharSerial()) == -1); Key = KdbpGetCharSerial();
switch (Key) switch (Key)
{ {
case 'A': case 'A':
@ -1954,7 +1958,9 @@ KdbpReadCommand(
} }
} }
else else
while ((Key = KdbpTryGetCharKeyboard(&ScanCode)) == -1); {
Key = KdbpGetCharKeyboard(&ScanCode);
}
if ((Buffer - Orig) >= (Size - 1)) if ((Buffer - Orig) >= (Size - 1))
{ {
@ -1965,10 +1971,13 @@ KdbpReadCommand(
if (Key == '\r') if (Key == '\r')
{ {
/* Ignore this key... */ /* Read the next char - this is to throw away a \n which most clients should
} * send after \r.
else if (Key == '\n') */
{ if (KdDebugState & KD_DEBUG_KDSERIAL)
NextKey = KdbpTryGetCharSerial(5);
else
NextKey = KdbpTryGetCharKeyboard(&ScanCode, 5);
DbgPrint("\n"); DbgPrint("\n");
/* /*
* Repeat the last command if the user presses enter. Reduces the * Repeat the last command if the user presses enter. Reduces the

View file

@ -62,12 +62,13 @@ VOID KbdDisableMouse()
} }
CHAR CHAR
KdbpTryGetCharKeyboard(PULONG ScanCode) KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry)
{ {
static byte_t last_key = 0; static byte_t last_key = 0;
static byte_t shift = 0; static byte_t shift = 0;
char c; char c;
while(1) { BOOLEAN KeepRetrying = (Retry == 0);
while (KeepRetrying || Retry-- > 0) {
unsigned char status = kbd_read_status(); unsigned char status = kbd_read_status();
while (status & KBD_STAT_OBF) { while (status & KBD_STAT_OBF) {
byte_t scancode; byte_t scancode;
@ -91,6 +92,8 @@ KdbpTryGetCharKeyboard(PULONG ScanCode)
} }
} }
} }
return -1;
} }
#endif #endif

View file

@ -20,11 +20,14 @@ extern KD_PORT_INFORMATION LogPortInfo;
CHAR CHAR
KdbpTryGetCharSerial() KdbpTryGetCharSerial(UINT Retry)
{ {
UCHAR Result; CHAR Result = -1;
while( !KdPortGetByteEx (&LogPortInfo, &Result) ); if (Retry == 0)
while (!KdPortGetByteEx(&LogPortInfo, (PUCHAR)&Result));
else
while (!KdPortGetByteEx(&LogPortInfo, (PUCHAR)&Result) && Retry-- > 0);
return Result; return Result;
} }