ReactOS  0.4.15-dev-5487-ge7bbbf0
kd.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cportlib/cportlib.h>
4 
5 //
6 // Kernel Debugger Port Definition
7 //
8 struct _KD_DISPATCH_TABLE;
9 
10 BOOLEAN
11 NTAPI
14  ULONG ComPortNumber
15 );
16 
17 BOOLEAN
18 NTAPI
21  PUCHAR ByteReceived);
22 
23 VOID
24 NTAPI
27  UCHAR ByteToSend
28 );
29 
30 #ifdef _NTOSKRNL_
31 
32 /* KD ROUTINES ***************************************************************/
33 
34 typedef enum _KD_CONTINUE_TYPE
35 {
36  kdContinue = 0,
37  kdDoNotHandleException,
38  kdHandleException
39 } KD_CONTINUE_TYPE;
40 
41 typedef
42 VOID
43 (NTAPI*PKDP_INIT_ROUTINE)(
44  struct _KD_DISPATCH_TABLE *DispatchTable,
45  ULONG BootPhase
46 );
47 
48 typedef
49 VOID
50 (NTAPI*PKDP_PRINT_ROUTINE)(
51  PCHAR String,
53 );
54 
55 /* INIT ROUTINES *************************************************************/
56 
57 VOID
59 
60 VOID
62 
63 VOID
64 NTAPI
66  struct _KD_DISPATCH_TABLE *DispatchTable,
67  ULONG BootPhase
68 );
69 
70 VOID
71 NTAPI
73  struct _KD_DISPATCH_TABLE *DispatchTable,
74  ULONG BootPhase
75 );
76 
77 VOID
78 NTAPI
80  struct _KD_DISPATCH_TABLE *DispatchTable,
81  ULONG BootPhase
82 );
83 
84 #ifdef KDBG
85 VOID
86 NTAPI
87 KdpKdbgInit(
88  struct _KD_DISPATCH_TABLE *DispatchTable,
89  ULONG BootPhase);
90 #endif
91 
92 
93 /* KD ROUTINES ***************************************************************/
94 
95 BOOLEAN
96 NTAPI
98  IN ULONG_PTR Addr,
99  IN LONG Len,
100  OUT PVOID Value
101 );
102 
103 BOOLEAN
104 NTAPI
106  IN ULONG_PTR Addr,
107  IN LONG Len,
109 );
110 
111 
112 /* KD GLOBALS ***************************************************************/
113 
114 /* Serial debug connection */
115 #define DEFAULT_DEBUG_PORT 2 /* COM2 */
116 #define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */
117 #define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */
118 #define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */
119 
120 /* KD Native Modes */
121 #define KdScreen 0
122 #define KdSerial 1
123 #define KdFile 2
124 #define KdKdbg 3
125 #define KdMax 4
126 
127 /* KD Private Debug Modes */
128 typedef struct _KDP_DEBUG_MODE
129 {
130  union
131  {
132  struct
133  {
134  /* Native Modes */
135  UCHAR Screen :1;
136  UCHAR Serial :1;
137  UCHAR File :1;
138  };
139 
140  /* Generic Value */
141  ULONG Value;
142  };
143 } KDP_DEBUG_MODE;
144 
145 /* KD Internal Debug Services */
146 typedef enum _KDP_DEBUG_SERVICE
147 {
148  DumpNonPagedPool = 0x1e, /* a */
149  ManualBugCheck = 0x30, /* b */
150  DumpNonPagedPoolStats = 0x2e, /* c */
151  DumpNewNonPagedPool = 0x20, /* d */
152  DumpNewNonPagedPoolStats = 0x12, /* e */
153  DumpAllThreads = 0x21, /* f */
154  DumpUserThreads = 0x22, /* g */
155  KdSpare1 = 0x23, /* h */
156  KdSpare2 = 0x17, /* i */
157  KdSpare3 = 0x24, /* j */
158  EnterDebugger = 0x25, /* k */
159  ThatsWhatSheSaid = 69 /* FIGURE IT OUT */
160 } KDP_DEBUG_SERVICE;
161 
162 /* Dispatch Table for Wrapper Functions */
163 typedef struct _KD_DISPATCH_TABLE
164 {
165  LIST_ENTRY KdProvidersList;
166  PKDP_INIT_ROUTINE KdpInitRoutine;
167  PKDP_PRINT_ROUTINE KdpPrintRoutine;
168 } KD_DISPATCH_TABLE, *PKD_DISPATCH_TABLE;
169 
170 /* The current Debugging Mode */
171 extern KDP_DEBUG_MODE KdpDebugMode;
172 
173 /* Port Information for the Serial Native Mode */
174 extern ULONG SerialPortNumber;
175 extern CPPORT SerialPortInfo;
176 
177 /* Init Functions for Native Providers */
178 extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
179 
180 /* Dispatch Tables for Native Providers */
181 extern KD_DISPATCH_TABLE DispatchTable[KdMax];
182 
183 /* The KD Native Provider List */
184 extern LIST_ENTRY KdProviders;
185 
186 #endif // _NTOSKRNL_
187 
188 #if DBG && defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c
189 #define ID_Win32PreServiceHook 'WSH0'
190 #define ID_Win32PostServiceHook 'WSH1'
191 typedef void (NTAPI *PKDBG_PRESERVICEHOOK)(ULONG, PULONG_PTR);
192 typedef ULONG_PTR (NTAPI *PKDBG_POSTSERVICEHOOK)(ULONG, ULONG_PTR);
193 extern PKDBG_PRESERVICEHOOK KeWin32PreServiceHook;
194 extern PKDBG_POSTSERVICEHOOK KeWin32PostServiceHook;
195 #endif
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:39
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
unsigned char * PUCHAR
Definition: retypes.h:3
IN CINT OUT PVOID PortInformation
Definition: dumpinfo.c:39
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:346
uint32_t ULONG_PTR
Definition: typedefs.h:65
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
BOOLEAN NTAPI KdPortInitializeEx(PCPPORT PortInformation, ULONG ComPortNumber)
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:512
long LONG
Definition: pedump.c:60
VOID KdpScreenRelease(VOID)
Definition: kdio.c:399
unsigned char BOOLEAN
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
BOOLEAN NTAPI KdpSafeReadMemory(ULONG_PTR Addr, LONG Len, PVOID Value)
Definition: kdmemsup.c:165
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:380
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
uint64_t ULONGLONG
Definition: typedefs.h:67
#define Len
Definition: deflate.h:82
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN NTAPI KdPortGetByteEx(PCPPORT PortInformation, PUCHAR ByteReceived)
BOOLEAN NTAPI KdpSafeWriteMemory(ULONG_PTR Addr, LONG Len, ULONGLONG Value)
Definition: kdmemsup.c:201
#define VOID
Definition: acefi.h:82
Definition: typedefs.h:119
PKDP_INIT_ROUTINE InitRoutines[KdMax]
Definition: kdio.c:52
CPPORT SerialPortInfo
Definition: kdio.c:34
ULONG SerialPortNumber
Definition: kdio.c:33
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:65
Definition: console.h:34
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:218
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID _In_ LONG _In_z_ PCHAR File
Definition: wdfdevice.h:4061
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:49