diff --git a/ntoskrnl/include/internal/kd.h b/ntoskrnl/include/internal/kd.h index 7cc2ec45922..96862d1ef7e 100644 --- a/ntoskrnl/include/internal/kd.h +++ b/ntoskrnl/include/internal/kd.h @@ -27,16 +27,8 @@ KdPortPutByteEx( UCHAR ByteToSend ); -/* SYMBOL ROUTINES **********************************************************/ - #ifdef _NTOSKRNL_ -#ifdef KDBG -# define KdbInit() KdbpCliInit() -#else -# define KdbInit() do { } while (0) -#endif - /* KD ROUTINES ***************************************************************/ typedef enum _KD_CONTINUE_TYPE @@ -89,11 +81,13 @@ KdpDebugLogInit( ULONG BootPhase ); +#ifdef KDBG VOID NTAPI KdpKdbgInit( struct _KD_DISPATCH_TABLE *DispatchTable, ULONG BootPhase); +#endif /* KD ROUTINES ***************************************************************/ @@ -193,7 +187,7 @@ extern KD_DISPATCH_TABLE DispatchTable[KdMax]; /* The KD Native Provider List */ extern LIST_ENTRY KdProviders; -#endif +#endif // _NTOSKRNL_ #if DBG && defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c #define ID_Win32PreServiceHook 'WSH0' diff --git a/ntoskrnl/io/iomgr/iomgr.c b/ntoskrnl/io/iomgr/iomgr.c index 06df1ceac8f..0e901c605e9 100644 --- a/ntoskrnl/io/iomgr/iomgr.c +++ b/ntoskrnl/io/iomgr/iomgr.c @@ -590,7 +590,7 @@ IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) #if !defined(_WINKD_) && defined(KDBG) /* Read KDB Data */ - KdbInit(); + KdbpCliInit(); /* I/O is now setup for disk access, so phase 3 */ KdInitSystem(3, LoaderBlock); diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c index 275971acd92..1b0cd821383 100644 --- a/ntoskrnl/kd/kdio.c +++ b/ntoskrnl/kd/kdio.c @@ -49,10 +49,15 @@ KDP_DEBUG_MODE KdpDebugMode; LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}; KD_DISPATCH_TABLE DispatchTable[KdMax]; -PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit, - KdpSerialInit, - KdpDebugLogInit, - KdpKdbgInit}; +PKDP_INIT_ROUTINE InitRoutines[KdMax] = +{ + KdpScreenInit, + KdpSerialInit, + KdpDebugLogInit, +#ifdef KDBG + KdpKdbgInit +#endif +}; static ULONG KdbgNextApiNumber = DbgKdContinueApi; static CONTEXT KdbgContext; @@ -155,7 +160,7 @@ KdpLoggerThread(PVOID Context) static VOID NTAPI KdpPrintToLogFile(PCHAR String, - ULONG StringLength) + ULONG Length) { KIRQL OldIrql; ULONG beg, end, num; @@ -168,8 +173,8 @@ KdpPrintToLogFile(PCHAR String, beg = KdpCurrentPosition; num = KdpFreeBytes; - if (StringLength < num) - num = StringLength; + if (Length < num) + num = Length; if (num != 0) { @@ -222,8 +227,6 @@ KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, if (BootPhase == 0) { - KdComPortInUse = NULL; - /* Write out the functions that we support for now */ DispatchTable->KdpInitRoutine = KdpDebugLogInit; DispatchTable->KdpPrintRoutine = KdpPrintToLogFile; @@ -303,19 +306,19 @@ KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, /* SERIAL FUNCTIONS **********************************************************/ -VOID +static VOID NTAPI -KdpSerialDebugPrint(PCHAR Message, - ULONG Length) +KdpSerialPrint(PCHAR String, + ULONG Length) { - PCHAR pch = (PCHAR)Message; + PCHAR pch = String; KIRQL OldIrql; /* Acquire the printing spinlock without waiting at raised IRQL */ OldIrql = KdpAcquireLock(&KdpSerialSpinLock); - /* Output the message */ - while (pch < Message + Length && *pch != '\0') + /* Output the string */ + while (pch < String + Length && *pch) { if (*pch == '\n') { @@ -340,7 +343,7 @@ KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, { /* Write out the functions that we support for now */ DispatchTable->KdpInitRoutine = KdpSerialInit; - DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint; + DispatchTable->KdpPrintRoutine = KdpSerialPrint; /* Initialize the Port */ if (!KdPortInitializeEx(&SerialPortInfo, SerialPortNumber)) @@ -396,21 +399,21 @@ KdpScreenRelease(VOID) } /* - * Screen debug logger function KdpScreenPrint() writes text messages into + * Screen debug logger function KdpScreenPrint() writes text strings into * KdpDmesgBuffer, using it as a circular buffer. KdpDmesgBuffer contents could * be later (re)viewed using dmesg command of kdbg. KdpScreenPrint() protects * KdpDmesgBuffer from simultaneous writes by use of KdpDmesgLogSpinLock. */ static VOID NTAPI -KdpScreenPrint(PCHAR Message, +KdpScreenPrint(PCHAR String, ULONG Length) { - PCHAR pch = (PCHAR)Message; + PCHAR pch = String; KIRQL OldIrql; ULONG beg, end, num; - while (pch < Message + Length && *pch) + while (pch < String + Length && *pch) { if (*pch == '\b') { @@ -453,7 +456,7 @@ KdpScreenPrint(PCHAR Message, KdpScreenLineBufferPos = KdpScreenLineLength; } - /* Dmesg: store Message in the buffer to show it later */ + /* Dmesg: store the string in the buffer to show it later */ if (KdbpIsInDmesgMode) return; @@ -473,12 +476,12 @@ KdpScreenPrint(PCHAR Message, end = (beg + num) % KdpDmesgBufferSize; if (end > beg) { - RtlCopyMemory(KdpDmesgBuffer + beg, Message, Length); + RtlCopyMemory(KdpDmesgBuffer + beg, String, Length); } else { - RtlCopyMemory(KdpDmesgBuffer + beg, Message, KdpDmesgBufferSize - beg); - RtlCopyMemory(KdpDmesgBuffer, Message + (KdpDmesgBufferSize - beg), end); + RtlCopyMemory(KdpDmesgBuffer + beg, String, KdpDmesgBufferSize - beg); + RtlCopyMemory(KdpDmesgBuffer, String + (KdpDmesgBufferSize - beg), end); } KdpDmesgCurrentPosition = end; @@ -491,7 +494,7 @@ KdpScreenPrint(PCHAR Message, /* Optional step(?): find out a way to notify about buffer exhaustion, * and possibly fall into kbd to use dmesg command: user will read - * debug messages before they will be wiped over by next writes. + * debug strings before they will be wiped over by next writes. */ } @@ -531,6 +534,25 @@ KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, } } +#ifdef KDBG +/* KDBG FUNCTIONS ************************************************************/ + +/* NOTE: This may be moved completely into kdb_symbols.c */ +VOID NTAPI +KdbInitialize(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase); + +VOID +NTAPI +KdpKdbgInit( + PKD_DISPATCH_TABLE DispatchTable, + ULONG BootPhase) +{ + /* Forward the call */ + KdbInitialize(DispatchTable, BootPhase); +} +#endif + + /* GENERAL FUNCTIONS *********************************************************/ BOOLEAN diff --git a/ntoskrnl/kd/wrappers/kdbg.c b/ntoskrnl/kd/wrappers/kdbg.c deleted file mode 100644 index 23655ac600b..00000000000 --- a/ntoskrnl/kd/wrappers/kdbg.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/kd/wrappers/kdbg.c - * PURPOSE: KDBG Wrapper for Kd - * - * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org) - */ - -#include -#define NDEBUG -#include - -VOID NTAPI -KdbInitialize(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase); - -/* FUNCTIONS *****************************************************************/ - -VOID -NTAPI -KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable, - ULONG BootPhase) -{ -#ifdef KDBG - /* Forward the call */ - KdbInitialize(DispatchTable, BootPhase); -#else - /* When KDBG is disabled, it is not used/initialized at all */ -#endif -} diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c index 2f2703b717c..f2e0088d006 100644 --- a/ntoskrnl/kdbg/kdb_symbols.c +++ b/ntoskrnl/kdbg/kdb_symbols.c @@ -368,7 +368,7 @@ KdbInitialize( if (BootPhase == 0) { /* Write out the functions that we support for now */ - DispatchTable->KdpInitRoutine = KdpKdbgInit; + DispatchTable->KdpInitRoutine = KdbInitialize; DispatchTable->KdpPrintRoutine = KdbDebugPrint; /* Register as a Provider */ @@ -382,7 +382,7 @@ KdbInitialize( * /LOADSYMBOLS={YES|NO}, /NOLOADSYMBOLS={YES|NO} */ ASSERT(KeLoaderBlock); p1 = KeLoaderBlock->LoadOptions; - while('\0' != *p1 && NULL != (p2 = strchr(p1, '/'))) + while ('\0' != *p1 && NULL != (p2 = strchr(p1, '/'))) { p2++; Found = 0; diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake index 67fe1186a14..1bef231351f 100644 --- a/ntoskrnl/ntos.cmake +++ b/ntoskrnl/ntos.cmake @@ -415,7 +415,6 @@ if(NOT _WINKD_) endif() list(APPEND SOURCE - ${REACTOS_SOURCE_DIR}/ntoskrnl/kd/wrappers/kdbg.c ${REACTOS_SOURCE_DIR}/ntoskrnl/kd/kdio.c ${REACTOS_SOURCE_DIR}/ntoskrnl/kd/kdmain.c)