Merge with 13846. Fixes QEMU+KDBG problem. Modified: branches/alex_devel_branch/reactos/Makefile Deleted: branches/alex_devel_branch/reactos/media/drivers/etc/KDB.init Added: branches/alex_devel_branch/reactos/media/drivers/etc/KDBinit Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb.h Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_keyboard.c Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_serial.c _____
Modified: branches/alex_devel_branch/reactos/Makefile --- branches/alex_devel_branch/reactos/Makefile 2005-03-06 02:34:18 UTC (rev 13846) +++ branches/alex_devel_branch/reactos/Makefile 2005-03-06 05:32:54 UTC (rev 13847) @@ -216,8 +216,8 @@
$(CP) media/nls/l_intl.nls $(BOOTCD_DIR)/reactos/l_intl.nls $(HALFVERBOSEECHO) [COPY] media/drivers/etc/services to $(BOOTCD_DIR)/reactos/services $(CP) media/drivers/etc/services $(BOOTCD_DIR)/reactos/services - $(HALFVERBOSEECHO) [COPY] media/drivers/etc/KDB.init to $(BOOTCD_DIR)/reactos/KDB.init - $(CP) media/drivers/etc/KDB.init $(BOOTCD_DIR)/reactos/KDB.init + $(HALFVERBOSEECHO) [COPY] media/drivers/etc/KDBinit to $(BOOTCD_DIR)/reactos/KDBinit + $(CP) media/drivers/etc/KDBinit $(BOOTCD_DIR)/reactos/KDBinit
bootcd_basic: bootcd_directory_layout bootcd_bootstrap_files bootcd_install_before
@@ -1045,8 +1045,8 @@ $(CP) media/nls/l_intl.nls $(INSTALL_DIR)/system32/casemap.nls $(HALFVERBOSEECHO) [INSTALL] media/drivers/etc/services to $(INSTALL_DIR)/system32/drivers/etc/services $(CP) media/drivers/etc/services $(INSTALL_DIR)/system32/drivers/etc/services - $(HALFVERBOSEECHO) [INSTALL] media/drivers/etc/KDB.init to $(INSTALL_DIR)/system32/drivers/etc/KDB.init - $(CP) media/drivers/etc/KDB.init $(INSTALL_DIR)/system32/drivers/etc/KDB.init + $(HALFVERBOSEECHO) [INSTALL] media/drivers/etc/KDBinit to $(INSTALL_DIR)/system32/drivers/etc/KDBinit + $(CP) media/drivers/etc/KDBinit $(INSTALL_DIR)/system32/drivers/etc/KDBinit
.PHONY: install_clean install_dirs install_before
_____
Deleted: branches/alex_devel_branch/reactos/media/drivers/etc/KDB.init --- branches/alex_devel_branch/reactos/media/drivers/etc/KDB.init 2005-03-06 02:34:18 UTC (rev 13846) +++ branches/alex_devel_branch/reactos/media/drivers/etc/KDB.init 2005-03-06 05:32:54 UTC (rev 13847) @@ -1,15 +0,0 @@
-# Example KDB.init file -# -# The disassembly flavor is set to "intel" (default is "at&t") and the -# - -# Set the disassembly flavor to "intel" (default is "at&t") -set syntax intel - -# Change the condition to enter KDB on INT3 to "always" (default is "kmode") -set condition INT3 first always - -# This is a special command available only in the KDB.init file - it breaks into -# KDB when it is interpreting the init file at startup. -#break - _____
Copied: branches/alex_devel_branch/reactos/media/drivers/etc/KDBinit (from rev 13846, trunk/reactos/media/drivers/etc/KDBinit) _____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb.h --- branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb.h 2005-03-06 02:34:18 UTC (rev 13846) +++ branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb.h 2005-03-06 05:32:54 UTC (rev 13847) @@ -272,10 +272,15 @@
#define KdbpSafeReadMemory(dst, src, size) MmSafeCopyFromUser(dst, src, size) #define KdbpSafeWriteMemory(dst, src, size) MmSafeCopyToUser(dst, src, size) + +#define KdbpGetCharKeyboard(ScanCode) KdbpTryGetCharKeyboard(ScanCode, 0) CHAR -KdbpTryGetCharKeyboard(PULONG ScanCode); -ULONG -KdbpTryGetCharSerial(VOID); +KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry); + +#define KdbpGetCharSerial() KdbpTryGetCharSerial(0) +CHAR +KdbpTryGetCharSerial(UINT Retry); + VOID KdbEnter(VOID); VOID _____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c --- branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c 2005-03-06 02:34:18 UTC (rev 13846) +++ branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c 2005-03-06 05:32:54 UTC (rev 13847) @@ -97,7 +97,7 @@
STATIC LONG KdbNumberOfRowsTerminal = -1; STATIC LONG KdbNumberOfColsTerminal = -1;
-PCHAR KdbInitFileBuffer = NULL; /* Buffer where KDB.init file is loaded into during initialization */ +PCHAR KdbInitFileBuffer = NULL; /* Buffer where KDBinit file is loaded into during initialization */
STATIC CONST struct { @@ -1682,6 +1682,7 @@ INT Length; INT i; INT RowsPrintedByTerminal; + ULONG ScanCode; va_list ap;
/* Check if the user has aborted output of the current command */ @@ -1703,20 +1704,17 @@ { /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ TerminalReportsSize = FALSE; - DbgPrint("\x1b[18t"); - i = 10; - while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1)); + //DbgPrint("\x1b[18t"); + c = KdbpTryGetCharSerial(10); if (c == KEY_ESC) { - i = 5; - while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1)); + c = KdbpTryGetCharSerial(5); if (c == '[') { Length = 0; for (;;) { - i = 5; - while ((i-- > 0) && ((c = KdbpTryGetCharSerial()) == -1)); + c = KdbpTryGetCharSerial(5); if (c == -1) break; Buffer[Length++] = c; @@ -1781,13 +1779,19 @@ if (KdbNumberOfColsPrinted > 0) DbgPrint("\n"); 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') { - /* 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. */ - while ((c = KdbpTryGetCharSerial()) == -1); + if (KdDebugState & KD_DEBUG_KDSERIAL) + c = KdbpTryGetCharSerial(5); + else + c = KdbpTryGetCharKeyboard(&ScanCode, 5); } DbgPrint("\n"); if (c == 'q') @@ -1914,7 +1918,7 @@ OUT PCHAR Buffer, IN ULONG Size) { - CHAR Key; + CHAR Key, NextKey; PCHAR Orig = Buffer; ULONG ScanCode = 0; BOOLEAN EchoOn; @@ -1929,14 +1933,14 @@ { if (KdDebugState & KD_DEBUG_KDSERIAL) { - while ((Key = KdbpTryGetCharSerial()) == -1); + Key = KdbpGetCharSerial(); ScanCode = 0; if (Key == KEY_ESC) /* ESC */ { - while ((Key = KdbpTryGetCharSerial()) == -1); + Key = KdbpGetCharSerial(); if (Key == '[') { - while ((Key = KdbpTryGetCharSerial()) == -1); + Key = KdbpGetCharSerial(); switch (Key) { case 'A': @@ -1954,7 +1958,9 @@ } } else - while ((Key = KdbpTryGetCharKeyboard(&ScanCode)) == -1); + { + Key = KdbpGetCharKeyboard(&ScanCode); + }
if ((Buffer - Orig) >= (Size - 1)) { @@ -1965,10 +1971,13 @@
if (Key == '\r') { - /* Ignore this key... */ - } - else if (Key == '\n') - { + /* Read the next char - this is to throw away a \n which most clients should + * send after \r. + */ + if (KdDebugState & KD_DEBUG_KDSERIAL) + NextKey = KdbpTryGetCharSerial(5); + else + NextKey = KdbpTryGetCharKeyboard(&ScanCode, 5); DbgPrint("\n"); /* * Repeat the last command if the user presses enter. Reduces the @@ -2197,7 +2206,7 @@ CHAR c;
/* Execute the commands in the init file */ - DbgPrint("KDB: Executing KDB.init file...\n"); + DbgPrint("KDB: Executing KDBinit file...\n"); p1 = KdbInitFileBuffer; while (p1[0] != '\0') { @@ -2228,12 +2237,12 @@ while (p1[0] == '\r' || p1[0] == '\n') p1++; } - DbgPrint("KDB: KDB.init executed\n"); + DbgPrint("KDB: KDBinit executed\n"); }
/*!\brief Called when KDB is initialized * - * Reads the KDB.init file from the SystemRoot\system32\drivers\etc directory and executes it. + * Reads the KDBinit file from the SystemRoot\system32\drivers\etc directory and executes it. */ VOID KdbpCliInit() @@ -2249,7 +2258,7 @@ ULONG OldEflags;
/* Initialize the object attributes */ - RtlInitUnicodeString(&FileName, L"\SystemRoot\system32\drivers\etc\KDB.init"); + RtlInitUnicodeString(&FileName, L"\SystemRoot\system32\drivers\etc\KDBinit"); InitializeObjectAttributes(&ObjectAttributes, &FileName, 0, NULL, NULL);
/* Open the file */ @@ -2258,7 +2267,7 @@ FILE_NO_INTERMEDIATE_BUFFERING); if (!NT_SUCCESS(Status)) { - DPRINT("Could not open \SystemRoot\system32\drivers\etc\KDB.init (Status 0x%x)", Status); + DPRINT("Could not open \SystemRoot\system32\drivers\etc\KDBinit (Status 0x%x)", Status); return; }
@@ -2268,7 +2277,7 @@ if (!NT_SUCCESS(Status)) { ZwClose(hFile); - DPRINT("Could not query size of \SystemRoot\system32\drivers\etc\KDB.init (Status 0x%x)", Status); + DPRINT("Could not query size of \SystemRoot\system32\drivers\etc\KDBinit (Status 0x%x)", Status); return; } FileSize = FileStdInfo.EndOfFile.u.LowPart; @@ -2278,7 +2287,7 @@ if (FileBuffer == NULL) { ZwClose(hFile); - DPRINT("Could not allocate %d bytes for KDB.init file\n", FileSize); + DPRINT("Could not allocate %d bytes for KDBinit file\n", FileSize); return; }
@@ -2288,7 +2297,7 @@ if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) { ExFreePool(FileBuffer); - DPRINT("Could not read KDB.init file into memory (Status 0x%lx)\n", Status); + DPRINT("Could not read KDBinit file into memory (Status 0x%lx)\n", Status); return; } FileSize = min(FileSize, Iosb.Information); _____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_keyboard.c --- branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_keyboard.c 2005-03-06 02:34:18 UTC (rev 13846) +++ branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_keyboard.c 2005-03-06 05:32:54 UTC (rev 13847) @@ -62,12 +62,13 @@
}
CHAR -KdbpTryGetCharKeyboard(PULONG ScanCode) +KdbpTryGetCharKeyboard(PULONG ScanCode, UINT Retry) { static byte_t last_key = 0; static byte_t shift = 0; char c; - while(1) { + BOOLEAN KeepRetrying = (Retry == 0); + while (KeepRetrying || Retry-- > 0) { unsigned char status = kbd_read_status(); while (status & KBD_STAT_OBF) { byte_t scancode; @@ -91,6 +92,8 @@ } } } + + return -1; }
#endif _____
Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_serial.c --- branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_serial.c 2005-03-06 02:34:18 UTC (rev 13846) +++ branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_serial.c 2005-03-06 05:32:54 UTC (rev 13847) @@ -20,11 +20,14 @@
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; }