mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[NTOS:KD] Cleanup of some old code.
- Remove KdbInit() macro and directly use KdbpCliInit() (since the place where it was used was already within an #ifdef KDBG block). - Declare KdpKdbgInit() only when KDBG is defined, move its definition into kdio.c and remove the legacy wrappers/kdbg.c file. And in KdbInitialize(), set KdpInitRoutine directly to the former, instead of using the KdpKdbgInit indirection. - Don't reset KdComPortInUse in KdpDebugLogInit(). - Minor refactorings: KdpSerialDebugPrint -> KdpSerialPrint and make it static; argument name "Message" -> "String", "StringLength" -> "Length".
This commit is contained in:
parent
98e585364b
commit
271b985981
6 changed files with 53 additions and 68 deletions
|
@ -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'
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <ntoskrnl.h>
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
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
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue