[NTOS:KD] Remove dead code
[reactos.git] / ntoskrnl / include / internal / kd.h
1 #pragma once
2
3 #include <cportlib/cportlib.h>
4
5 //
6 // Kernel Debugger Port Definition
7 //
8 struct _KD_DISPATCH_TABLE;
9 extern CPPORT GdbPortInfo;
10 extern BOOLEAN KdBreakAfterSymbolLoad;
11 extern BOOLEAN KdPitchDebugger;
12 extern BOOLEAN KdIgnoreUmExceptions;
13
14 BOOLEAN
15 NTAPI
16 KdPortInitializeEx(
17 PCPPORT PortInformation,
18 ULONG ComPortNumber
19 );
20
21 BOOLEAN
22 NTAPI
23 KdPortGetByteEx(
24 PCPPORT PortInformation,
25 PUCHAR ByteReceived);
26
27 VOID
28 NTAPI
29 KdPortPutByteEx(
30 PCPPORT PortInformation,
31 UCHAR ByteToSend
32 );
33
34 /* SYMBOL ROUTINES **********************************************************/
35 #ifdef __NTOSKRNL__
36
37 #if defined(KDBG) || DBG
38
39 #if defined(KDBG)
40 typedef
41 BOOLEAN
42 (NTAPI *PKDBG_CLI_ROUTINE)(
43 IN PCHAR Command,
44 IN ULONG Argc,
45 IN PCH Argv[]);
46
47 BOOLEAN
48 NTAPI
49 KdbRegisterCliCallback(
50 PVOID Callback,
51 BOOLEAN Deregister);
52 #endif
53
54 VOID
55 KdbSymProcessSymbols(
56 IN PLDR_DATA_TABLE_ENTRY LdrEntry);
57
58
59 BOOLEAN
60 KdbSymPrintAddress(
61 IN PVOID Address,
62 IN PKTRAP_FRAME Context
63 );
64
65 NTSTATUS
66 KdbSymGetAddressInformation(
67 IN PROSSYM_INFO RosSymInfo,
68 IN ULONG_PTR RelativeAddress,
69 #ifdef __ROS_DWARF__
70 IN PROSSYM_LINEINFO RosSymLineInfo
71 #else
72 OUT PULONG LineNumber OPTIONAL,
73 OUT PCH FileName OPTIONAL,
74 OUT PCH FunctionName OPTIONAL
75 #endif
76 );
77 #endif
78
79 #ifdef KDBG
80 # define KdbInit() KdbpCliInit()
81 # define KdbModuleLoaded(FILENAME) KdbpCliModuleLoaded(FILENAME)
82 #else
83 # define KdbEnterDebuggerException(ER, PM, C, TF, F) kdHandleException
84 # define KdbInit() do { } while (0)
85 # define KdbEnter() do { } while (0)
86 # define KdbModuleLoaded(X) do { } while (0)
87 #endif
88
89 /* KD ROUTINES ***************************************************************/
90
91 typedef enum _KD_CONTINUE_TYPE
92 {
93 kdContinue = 0,
94 kdDoNotHandleException,
95 kdHandleException
96 }
97 KD_CONTINUE_TYPE;
98
99 typedef
100 VOID
101 (NTAPI*PKDP_INIT_ROUTINE)(
102 struct _KD_DISPATCH_TABLE *DispatchTable,
103 ULONG BootPhase
104 );
105
106 typedef
107 VOID
108 (NTAPI*PKDP_PRINT_ROUTINE)(
109 LPSTR String,
110 ULONG Length
111 );
112
113 typedef
114 VOID
115 (NTAPI*PKDP_PROMPT_ROUTINE)(PCH String);
116
117 typedef
118 KD_CONTINUE_TYPE
119 (NTAPI*PKDP_EXCEPTION_ROUTINE)(
120 PEXCEPTION_RECORD ExceptionRecord,
121 PCONTEXT Context,
122 PKTRAP_FRAME TrapFrame
123 );
124
125 BOOLEAN
126 NTAPI
127 KdIsThisAKdTrap(
128 IN PEXCEPTION_RECORD ExceptionRecord,
129 IN PCONTEXT Context,
130 IN KPROCESSOR_MODE PreviousMode
131 );
132
133 /* INIT ROUTINES *************************************************************/
134
135 BOOLEAN
136 NTAPI
137 KdInitSystem(
138 ULONG Reserved,
139 PLOADER_PARAMETER_BLOCK LoaderBlock
140 );
141
142 VOID
143 NTAPI
144 KdpScreenInit(
145 struct _KD_DISPATCH_TABLE *DispatchTable,
146 ULONG BootPhase
147 );
148
149 VOID
150 NTAPI
151 KdpSerialInit(
152 struct _KD_DISPATCH_TABLE *DispatchTable,
153 ULONG BootPhase
154 );
155
156 VOID
157 NTAPI
158 KdpInitDebugLog(
159 struct _KD_DISPATCH_TABLE *DispatchTable,
160 ULONG BootPhase
161 );
162
163 VOID
164 NTAPI
165 KdpBochsInit(
166 struct _KD_DISPATCH_TABLE *DispatchTable,
167 ULONG BootPhase
168 );
169
170 VOID
171 NTAPI
172 KdpGdbStubInit(
173 struct _KD_DISPATCH_TABLE *DispatchTable,
174 ULONG BootPhase);
175
176 VOID
177 NTAPI
178 KdpKdbgInit(
179 struct _KD_DISPATCH_TABLE *DispatchTable,
180 ULONG BootPhase);
181
182
183 /* KD ROUTINES ***************************************************************/
184
185 ULONG
186 NTAPI
187 KdpPrintString(
188 _In_reads_bytes_(Length) PCHAR UnsafeString,
189 _In_ ULONG Length,
190 _In_ KPROCESSOR_MODE PreviousMode);
191
192 ULONG
193 NTAPI
194 KdpPrompt(
195 _In_reads_bytes_(InStringLength) PCHAR UnsafeInString,
196 _In_ USHORT InStringLength,
197 _Out_writes_bytes_(OutStringLength) PCHAR UnsafeOutString,
198 _In_ USHORT OutStringLength,
199 _In_ KPROCESSOR_MODE PreviousMode
200 );
201
202 BOOLEAN
203 NTAPI
204 KdpDetectConflicts(PCM_RESOURCE_LIST DriverList);
205
206 VOID
207 NTAPI
208 KdpBochsDebugPrint(
209 IN PCH Message,
210 IN ULONG Length
211 );
212
213 BOOLEAN
214 NTAPI
215 KdpSafeReadMemory(
216 IN ULONG_PTR Addr,
217 IN LONG Len,
218 OUT PVOID Value
219 );
220
221 BOOLEAN
222 NTAPI
223 KdpSafeWriteMemory(
224 IN ULONG_PTR Addr,
225 IN LONG Len,
226 IN ULONGLONG Value
227 );
228
229 VOID
230 NTAPI
231 KdpEnableSafeMem(VOID);
232
233
234 /* KD GLOBALS ***************************************************************/
235
236 typedef
237 BOOLEAN
238 (NTAPI *PKDEBUG_ROUTINE)(
239 IN PKTRAP_FRAME TrapFrame,
240 IN PKEXCEPTION_FRAME ExceptionFrame,
241 IN PEXCEPTION_RECORD ExceptionRecord,
242 IN PCONTEXT Context,
243 IN KPROCESSOR_MODE PreviousMode,
244 IN BOOLEAN SecondChance
245 );
246
247 /* serial debug connection */
248 #define DEFAULT_DEBUG_PORT 2 /* COM2 */
249 #define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */
250 #define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */
251 #define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */
252
253 /* KD Native Modes */
254 #define KdScreen 0
255 #define KdSerial 1
256 #define KdFile 2
257 #define KdBochs 3
258 #define KdKdbg 4
259 #define KdMax 5
260
261 /* KD Private Debug Modes */
262 typedef struct _KDP_DEBUG_MODE
263 {
264 union
265 {
266 struct
267 {
268 /* Native Modes */
269 UCHAR Screen :1;
270 UCHAR Serial :1;
271 UCHAR File :1;
272 UCHAR Bochs :1;
273
274 /* Currently Supported Wrappers */
275 UCHAR Pice :1;
276 UCHAR Gdb :1;
277 };
278
279 /* Generic Value */
280 ULONG Value;
281 };
282 }
283 KDP_DEBUG_MODE;
284
285 /* KD Internal Debug Services */
286 typedef enum _KDP_DEBUG_SERVICE
287 {
288 DumpNonPagedPool = 0x1e, /* a */
289 ManualBugCheck = 0x30, /* b */
290 DumpNonPagedPoolStats = 0x2e, /* c */
291 DumpNewNonPagedPool = 0x20, /* d */
292 DumpNewNonPagedPoolStats = 0x12, /* e */
293 DumpAllThreads = 0x21, /* f */
294 DumpUserThreads = 0x22, /* g */
295 KdSpare1 = 0x23, /* h */
296 KdSpare2 = 0x17, /* i */
297 KdSpare3 = 0x24, /* j */
298 EnterDebugger = 0x25, /* k */
299 ThatsWhatSheSaid = 69 /* FIGURE IT OUT */
300 }
301 KDP_DEBUG_SERVICE;
302
303 /* Dispatch Table for Wrapper Functions */
304 typedef struct _KD_DISPATCH_TABLE
305 {
306 LIST_ENTRY KdProvidersList;
307 PKDP_INIT_ROUTINE KdpInitRoutine;
308 PKDP_PRINT_ROUTINE KdpPrintRoutine;
309 PKDP_PROMPT_ROUTINE KdpPromptRoutine;
310 PKDP_EXCEPTION_ROUTINE KdpExceptionRoutine;
311 }
312 KD_DISPATCH_TABLE, *PKD_DISPATCH_TABLE;
313
314 /* The current Debugging Mode */
315 extern KDP_DEBUG_MODE KdpDebugMode;
316
317 /* The current Port IRQ */
318 extern ULONG KdpPortIrq;
319
320 /* The current Port */
321 extern ULONG KdpPort;
322
323 /* Port Information for the Serial Native Mode */
324 extern ULONG SerialPortNumber;
325 extern CPPORT SerialPortInfo;
326
327 /* Init Functions for Native Providers */
328 extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
329
330 /* Wrapper Init Function */
331 extern PKDP_INIT_ROUTINE WrapperInitRoutine;
332
333 /* Dispatch Tables for Native Providers */
334 extern KD_DISPATCH_TABLE DispatchTable[KdMax];
335
336 /* Dispatch Table for the Wrapper */
337 extern KD_DISPATCH_TABLE WrapperTable;
338
339 /* The KD Native Provider List */
340 extern LIST_ENTRY KdProviders;
341
342 extern PKDEBUG_ROUTINE KiDebugRoutine;
343 extern KD_CONTEXT KdpContext;
344 extern ULONG Kd_WIN2000_Mask;
345
346 #endif
347
348 #if DBG && defined(_M_IX86) && !defined(_WINKD_) // See ke/i386/traphdlr.c
349 #define ID_Win32PreServiceHook 'WSH0'
350 #define ID_Win32PostServiceHook 'WSH1'
351 typedef void (NTAPI *PKDBG_PRESERVICEHOOK)(ULONG, PULONG_PTR);
352 typedef ULONG_PTR (NTAPI *PKDBG_POSTSERVICEHOOK)(ULONG, ULONG_PTR);
353 extern PKDBG_PRESERVICEHOOK KeWin32PreServiceHook;
354 extern PKDBG_POSTSERVICEHOOK KeWin32PostServiceHook;
355 #endif