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