https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eb02a852144c89f82b236…
commit eb02a852144c89f82b236b29160408edb6002230
Author:     Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Mar 27 23:13:53 2023 +0200
Commit:     Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Mar 27 23:31:34 2023 +0200
    [NTOS:KD] Split internal/kd.h into a part shared in the whole kernel and a private
part only used within ntoskrnl/kd.
---
 ntoskrnl/include/internal/kd.h         | 116 +--------------------------------
 ntoskrnl/{include/internal => kd}/kd.h |  71 ++------------------
 ntoskrnl/kd/kdmain.c                   |   4 --
 ntoskrnl/kdbg/kdb.h                    |   2 +-
 4 files changed, 8 insertions(+), 185 deletions(-)
diff --git a/ntoskrnl/include/internal/kd.h b/ntoskrnl/include/internal/kd.h
index 64b83e7a168..a180acf5478 100644
--- a/ntoskrnl/include/internal/kd.h
+++ b/ntoskrnl/include/internal/kd.h
@@ -5,7 +5,6 @@
 //
 // Kernel Debugger Port Definition
 //
-struct _KD_DISPATCH_TABLE;
 BOOLEAN
 NTAPI
@@ -29,7 +28,7 @@ KdPortPutByteEx(
 #ifdef _NTOSKRNL_
-/* KD ROUTINES ***************************************************************/
+/* KD GLOBALS ****************************************************************/
 typedef enum _KD_CONTINUE_TYPE
 {
@@ -38,94 +37,6 @@ typedef enum _KD_CONTINUE_TYPE
     kdHandleException
 } KD_CONTINUE_TYPE;
-typedef
-NTSTATUS
-(NTAPI *PKDP_INIT_ROUTINE)(
-    _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
-    _In_ ULONG BootPhase);
-
-typedef
-VOID
-(NTAPI*PKDP_PRINT_ROUTINE)(
-    PCHAR String,
-    ULONG Length
-);
-
-/* INIT ROUTINES *************************************************************/
-
-KIRQL
-NTAPI
-KdbpAcquireLock(
-    _In_ PKSPIN_LOCK SpinLock);
-
-VOID
-NTAPI
-KdbpReleaseLock(
-    _In_ PKSPIN_LOCK SpinLock,
-    _In_ KIRQL OldIrql);
-
-VOID
-KdpScreenAcquire(VOID);
-
-VOID
-KdpScreenRelease(VOID);
-
-NTSTATUS
-NTAPI
-KdpScreenInit(
-    _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
-    _In_ ULONG BootPhase);
-
-NTSTATUS
-NTAPI
-KdpSerialInit(
-    _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
-    _In_ ULONG BootPhase);
-
-NTSTATUS
-NTAPI
-KdpDebugLogInit(
-    _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
-    _In_ ULONG BootPhase);
-
-#ifdef KDBG
-#define KdpKdbgInit KdbInitialize
-#endif
-
-
-/* KD GLOBALS  ***************************************************************/
-
-/* Serial debug connection */
-#define DEFAULT_DEBUG_PORT      2 /* COM2 */
-#define DEFAULT_DEBUG_COM1_IRQ  4 /* COM1 IRQ */
-#define DEFAULT_DEBUG_COM2_IRQ  3 /* COM2 IRQ */
-#define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */
-
-/* KD Native Modes */
-#define KdScreen    0
-#define KdSerial    1
-#define KdFile      2
-#define KdKdbg      3
-#define KdMax       4
-
-/* KD Private Debug Modes */
-typedef struct _KDP_DEBUG_MODE
-{
-    union
-    {
-        struct
-        {
-            /* Native Modes */
-            UCHAR Screen :1;
-            UCHAR Serial :1;
-            UCHAR File   :1;
-        };
-
-        /* Generic Value */
-        ULONG Value;
-    };
-} KDP_DEBUG_MODE;
-
 /* KD Internal Debug Services */
 typedef enum _KDP_DEBUG_SERVICE
 {
@@ -143,31 +54,6 @@ typedef enum _KDP_DEBUG_SERVICE
     ThatsWhatSheSaid = 69 /* FIGURE IT OUT */
 } KDP_DEBUG_SERVICE;
-/* Dispatch Table for Wrapper Functions */
-typedef struct _KD_DISPATCH_TABLE
-{
-    LIST_ENTRY KdProvidersList;
-    PKDP_INIT_ROUTINE KdpInitRoutine;
-    PKDP_PRINT_ROUTINE KdpPrintRoutine;
-    NTSTATUS InitStatus;
-} KD_DISPATCH_TABLE, *PKD_DISPATCH_TABLE;
-
-/* The current Debugging Mode */
-extern KDP_DEBUG_MODE KdpDebugMode;
-
-/* Port Information for the Serial Native Mode */
-extern ULONG  SerialPortNumber;
-extern CPPORT SerialPortInfo;
-
-/* Init Functions for Native Providers */
-extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
-
-/* Dispatch Tables for Native Providers */
-extern KD_DISPATCH_TABLE DispatchTable[KdMax];
-
-/* The KD Native Provider List */
-extern LIST_ENTRY KdProviders;
-
 #endif // _NTOSKRNL_
 #if DBG && defined(_M_IX86) && !defined(_WINKD_) // See
ke/i386/traphdlr.c
diff --git a/ntoskrnl/include/internal/kd.h b/ntoskrnl/kd/kd.h
similarity index 60%
copy from ntoskrnl/include/internal/kd.h
copy to ntoskrnl/kd/kd.h
index 64b83e7a168..5672408d4c6 100644
--- a/ntoskrnl/include/internal/kd.h
+++ b/ntoskrnl/kd/kd.h
@@ -1,42 +1,8 @@
 #pragma once
-#include <cportlib/cportlib.h>
-
-//
-// Kernel Debugger Port Definition
-//
-struct _KD_DISPATCH_TABLE;
-
-BOOLEAN
-NTAPI
-KdPortInitializeEx(
-    PCPPORT PortInformation,
-    ULONG ComPortNumber
-);
-
-BOOLEAN
-NTAPI
-KdPortGetByteEx(
-    PCPPORT PortInformation,
-    PUCHAR ByteReceived);
-
-VOID
-NTAPI
-KdPortPutByteEx(
-    PCPPORT PortInformation,
-    UCHAR ByteToSend
-);
-
-#ifdef _NTOSKRNL_
-
 /* KD ROUTINES ***************************************************************/
-typedef enum _KD_CONTINUE_TYPE
-{
-    kdContinue = 0,
-    kdDoNotHandleException,
-    kdHandleException
-} KD_CONTINUE_TYPE;
+struct _KD_DISPATCH_TABLE;
 typedef
 NTSTATUS
@@ -46,7 +12,7 @@ NTSTATUS
 typedef
 VOID
-(NTAPI*PKDP_PRINT_ROUTINE)(
+(NTAPI *PKDP_PRINT_ROUTINE)(
     PCHAR String,
     ULONG Length
 );
@@ -93,7 +59,7 @@ KdpDebugLogInit(
 #endif
-/* KD GLOBALS  ***************************************************************/
+/* KD GLOBALS ****************************************************************/
 /* Serial debug connection */
 #define DEFAULT_DEBUG_PORT      2 /* COM2 */
@@ -126,23 +92,6 @@ typedef struct _KDP_DEBUG_MODE
     };
 } KDP_DEBUG_MODE;
-/* KD Internal Debug Services */
-typedef enum _KDP_DEBUG_SERVICE
-{
-    DumpNonPagedPool = 0x1e, /* a */
-    ManualBugCheck = 0x30, /* b */
-    DumpNonPagedPoolStats = 0x2e, /* c */
-    DumpNewNonPagedPool = 0x20, /* d */
-    DumpNewNonPagedPoolStats = 0x12, /* e */
-    DumpAllThreads = 0x21, /* f */
-    DumpUserThreads = 0x22, /* g */
-    KdSpare1 = 0x23, /* h */
-    KdSpare2 = 0x17, /* i */
-    KdSpare3 = 0x24, /* j */
-    EnterDebugger = 0x25,  /* k */
-    ThatsWhatSheSaid = 69 /* FIGURE IT OUT */
-} KDP_DEBUG_SERVICE;
-
 /* Dispatch Table for Wrapper Functions */
 typedef struct _KD_DISPATCH_TABLE
 {
@@ -159,6 +108,9 @@ extern KDP_DEBUG_MODE KdpDebugMode;
 extern ULONG  SerialPortNumber;
 extern CPPORT SerialPortInfo;
+/* Logging file path */
+extern ANSI_STRING KdpLogFileName;
+
 /* Init Functions for Native Providers */
 extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
@@ -167,14 +119,3 @@ extern KD_DISPATCH_TABLE DispatchTable[KdMax];
 /* The KD Native Provider List */
 extern LIST_ENTRY KdProviders;
-
-#endif // _NTOSKRNL_
-
-#if DBG && defined(_M_IX86) && !defined(_WINKD_) // See
ke/i386/traphdlr.c
-#define ID_Win32PreServiceHook 'WSH0'
-#define ID_Win32PostServiceHook 'WSH1'
-typedef void (NTAPI *PKDBG_PRESERVICEHOOK)(ULONG, PULONG_PTR);
-typedef ULONG_PTR (NTAPI *PKDBG_POSTSERVICEHOOK)(ULONG, ULONG_PTR);
-extern PKDBG_PRESERVICEHOOK KeWin32PreServiceHook;
-extern PKDBG_POSTSERVICEHOOK KeWin32PostServiceHook;
-#endif
diff --git a/ntoskrnl/kd/kdmain.c b/ntoskrnl/kd/kdmain.c
index 6281f43ab8f..77515b0bf3c 100644
--- a/ntoskrnl/kd/kdmain.c
+++ b/ntoskrnl/kd/kdmain.c
@@ -11,10 +11,6 @@
 #define NDEBUG
 #include <debug.h>
-/* VARIABLES ***************************************************************/
-
-extern ANSI_STRING KdpLogFileName;
-
 /* PUBLIC FUNCTIONS *********************************************************/
 static PCHAR
diff --git a/ntoskrnl/kdbg/kdb.h b/ntoskrnl/kdbg/kdb.h
index 6a5027ec2e8..cd7a0b5bec6 100644
--- a/ntoskrnl/kdbg/kdb.h
+++ b/ntoskrnl/kdbg/kdb.h
@@ -1,5 +1,5 @@
 #pragma once
-#include "internal/kd.h"
+#include "../kd/kd.h"
 /* TYPES *********************************************************************/