[NTOS:KD] Split internal/kd.h into a part shared in the whole kernel and a private part only used within ntoskrnl/kd.

This commit is contained in:
Hermès Bélusca-Maïto 2023-03-27 23:13:53 +02:00
parent bfd07a02f1
commit eb02a85214
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 123 additions and 120 deletions

View file

@ -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

121
ntoskrnl/kd/kd.h Normal file
View file

@ -0,0 +1,121 @@
#pragma once
/* KD ROUTINES ***************************************************************/
struct _KD_DISPATCH_TABLE;
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;
/* 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;
/* Logging file path */
extern ANSI_STRING KdpLogFileName;
/* 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;

View file

@ -11,10 +11,6 @@
#define NDEBUG
#include <debug.h>
/* VARIABLES ***************************************************************/
extern ANSI_STRING KdpLogFileName;
/* PUBLIC FUNCTIONS *********************************************************/
static PCHAR

View file

@ -1,5 +1,5 @@
#pragma once
#include "internal/kd.h"
#include "../kd/kd.h"
/* TYPES *********************************************************************/