- Add STATUS_SUCCESS to asm.h and make use of it.
[reactos.git] / reactos / ntoskrnl / include / internal / kd64.h
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/kd64.h
5 * PURPOSE: Internal header for the KD64 Library
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 //
10 // Maximum supported number of breakpoints
11 //
12 #define KD_BREAKPOINT_MAX 32
13
14 //
15 // Breakpoint Status Flags
16 //
17 typedef enum _KDP_BREAKPOINT_FLAGS
18 {
19 KdpBreakpointActive = 1,
20 KdpBreakpointPending = 2,
21 KdpBreakpointSuspended = 4,
22 KdpBreakpointExpired = 8
23 } KDP_BREAKPOINT_FLAGS;
24
25 //
26 // Structure for Breakpoints
27 //
28 typedef struct _BREAKPOINT_ENTRY
29 {
30 ULONG Flags;
31 PKPROCESS Process;
32 PVOID Address;
33 KD_BREAKPOINT_TYPE Content;
34 } BREAKPOINT_ENTRY, *PBREAKPOINT_ENTRY;
35
36 //
37 // Debug and Multi-Processor Switch Routine Definitions
38 //
39 typedef
40 BOOLEAN
41 (NTAPI *PKDEBUG_ROUTINE)(
42 IN PKTRAP_FRAME TrapFrame,
43 IN PKEXCEPTION_FRAME ExceptionFrame,
44 IN PEXCEPTION_RECORD ExceptionRecord,
45 IN PCONTEXT Context,
46 IN KPROCESSOR_MODE PreviousMode,
47 IN BOOLEAN SecondChance
48 );
49
50 typedef
51 BOOLEAN
52 (NTAPI *PKDEBUG_SWITCH_ROUTINE)(
53 IN PEXCEPTION_RECORD ExceptionRecord,
54 IN PCONTEXT Context,
55 IN BOOLEAN SecondChance
56 );
57
58 //
59 // Initialization Routines
60 //
61 BOOLEAN
62 NTAPI
63 KdInitSystem(
64 ULONG Reserved,
65 PLOADER_PARAMETER_BLOCK LoaderBlock
66 );
67
68 VOID
69 NTAPI
70 KdUpdateDataBlock(
71 VOID
72 );
73
74 //
75 // Determines if the kernel debugger must handle a particular trap
76 //
77 BOOLEAN
78 NTAPI
79 KdIsThisAKdTrap(
80 IN PEXCEPTION_RECORD ExceptionRecord,
81 IN PCONTEXT Context,
82 IN KPROCESSOR_MODE PreviousMode
83 );
84
85 //
86 // Multi-Processor Switch Support
87 //
88 BOOLEAN
89 NTAPI
90 KdpSwitchProcessor(
91 IN PEXCEPTION_RECORD ExceptionRecord,
92 IN OUT PCONTEXT ContextRecord,
93 IN BOOLEAN SecondChanceException
94 );
95
96 //
97 // Time Slip Support
98 //
99 VOID
100 NTAPI
101 KdpTimeSlipWork(
102 IN PVOID Context
103 );
104
105 VOID
106 NTAPI
107 KdpTimeSlipDpcRoutine(
108 IN PKDPC Dpc,
109 IN PVOID DeferredContext,
110 IN PVOID SystemArgument1,
111 IN PVOID SystemArgument2
112 );
113
114 //
115 // Debug Trap Handlers
116 //
117 BOOLEAN
118 NTAPI
119 KdpStub(
120 IN PKTRAP_FRAME TrapFrame,
121 IN PKEXCEPTION_FRAME ExceptionFrame,
122 IN PEXCEPTION_RECORD ExceptionRecord,
123 IN PCONTEXT ContextRecord,
124 IN KPROCESSOR_MODE PreviousMode,
125 IN BOOLEAN SecondChanceException
126 );
127
128 BOOLEAN
129 NTAPI
130 KdpTrap(
131 IN PKTRAP_FRAME TrapFrame,
132 IN PKEXCEPTION_FRAME ExceptionFrame,
133 IN PEXCEPTION_RECORD ExceptionRecord,
134 IN PCONTEXT ContextRecord,
135 IN KPROCESSOR_MODE PreviousMode,
136 IN BOOLEAN SecondChanceException
137 );
138
139 //
140 // Port Locking
141 //
142 VOID
143 NTAPI
144 KdpPortLock(
145 VOID
146 );
147
148 VOID
149 NTAPI
150 KdpPortUnlock(
151 VOID
152 );
153
154 BOOLEAN
155 NTAPI
156 KdpPollBreakInWithPortLock(
157 VOID
158 );
159
160 //
161 // Debugger Enter, Exit, Enable and Disable
162 //
163 BOOLEAN
164 NTAPI
165 KdEnterDebugger(
166 IN PKTRAP_FRAME TrapFrame,
167 IN PKEXCEPTION_FRAME ExceptionFrame
168 );
169
170 VOID
171 NTAPI
172 KdExitDebugger(
173 IN BOOLEAN Entered
174 );
175
176 NTSTATUS
177 NTAPI
178 KdEnableDebuggerWithLock(
179 IN BOOLEAN NeedLock
180 );
181
182 NTSTATUS
183 NTAPI
184 KdDisableDebuggerWithLock(
185 IN BOOLEAN NeedLock
186 );
187
188 //
189 // Debug Event Handlers
190 //
191 NTSTATUS
192 NTAPI
193 KdpPrint(
194 IN ULONG ComponentId,
195 IN ULONG ComponentMask,
196 IN LPSTR String,
197 IN USHORT Length,
198 IN KPROCESSOR_MODE PreviousMode,
199 IN PKTRAP_FRAME TrapFrame,
200 IN PKEXCEPTION_FRAME ExceptionFrame,
201 OUT PBOOLEAN Status
202 );
203
204 BOOLEAN
205 NTAPI
206 KdpPrompt(
207 IN LPSTR InString,
208 IN USHORT InStringLength,
209 OUT LPSTR OutString,
210 IN USHORT OutStringLength,
211 IN KPROCESSOR_MODE PreviousMode,
212 IN PKTRAP_FRAME TrapFrame,
213 IN PKEXCEPTION_FRAME ExceptionFrame
214 );
215
216 VOID
217 NTAPI
218 KdpSymbol(
219 IN PSTRING DllPath,
220 IN PKD_SYMBOLS_INFO DllBase,
221 IN BOOLEAN Unload,
222 IN KPROCESSOR_MODE PreviousMode,
223 IN PCONTEXT ContextRecord,
224 IN PKTRAP_FRAME TrapFrame,
225 IN PKEXCEPTION_FRAME ExceptionFrame
226 );
227
228 VOID
229 NTAPI
230 KdpCommandString(
231 IN ULONG Length,
232 IN LPSTR String,
233 IN KPROCESSOR_MODE PreviousMode,
234 IN PCONTEXT ContextRecord,
235 IN PKTRAP_FRAME TrapFrame,
236 IN PKEXCEPTION_FRAME ExceptionFrame
237 );
238
239 //
240 // State Change Notifications
241 //
242 BOOLEAN
243 NTAPI
244 KdpReportLoadSymbolsStateChange(
245 IN PSTRING PathName,
246 IN PKD_SYMBOLS_INFO SymbolInfo,
247 IN BOOLEAN Unload,
248 IN OUT PCONTEXT Context
249 );
250
251 BOOLEAN
252 NTAPI
253 KdpReportExceptionStateChange(
254 IN PEXCEPTION_RECORD ExceptionRecord,
255 IN OUT PCONTEXT Context,
256 IN BOOLEAN SecondChanceException
257 );
258
259 //
260 // Breakpoint Support
261 //
262 ULONG
263 NTAPI
264 KdpAddBreakpoint(
265 IN PVOID Address
266 );
267
268 BOOLEAN
269 NTAPI
270 KdpDeleteBreakpoint(
271 IN ULONG BpEntry
272 );
273
274 BOOLEAN
275 NTAPI
276 KdpDeleteBreakpointRange(
277 IN PVOID Base,
278 IN PVOID Limit
279 );
280
281 VOID
282 NTAPI
283 KdpSuspendBreakPoint(
284 IN ULONG BpEntry
285 );
286
287 VOID
288 NTAPI
289 KdpRestoreAllBreakpoints(
290 VOID
291 );
292
293 VOID
294 NTAPI
295 KdpSuspendAllBreakPoints(
296 VOID
297 );
298
299 //
300 // Architecture dependent support routines
301 //
302
303 //
304 // Version
305 //
306 VOID
307 NTAPI
308 KdpSysGetVersion(
309 IN PDBGKD_GET_VERSION64 Version
310 );
311
312 //
313 // Context
314 //
315 VOID
316 NTAPI
317 KdpGetStateChange(
318 IN PDBGKD_MANIPULATE_STATE64 State,
319 IN PCONTEXT Context
320 );
321
322 VOID
323 NTAPI
324 KdpSetContextState(
325 IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
326 IN PCONTEXT Context
327 );
328
329 //
330 // MSR
331 //
332 NTSTATUS
333 NTAPI
334 KdpSysReadMsr(
335 IN ULONG Msr,
336 OUT PLARGE_INTEGER MsrValue
337 );
338
339 NTSTATUS
340 NTAPI
341 KdpSysWriteMsr(
342 IN ULONG Msr,
343 IN PLARGE_INTEGER MsrValue
344 );
345
346 //
347 // Bus
348 //
349 NTSTATUS
350 NTAPI
351 KdpSysReadBusData(
352 IN ULONG BusDataType,
353 IN ULONG BusNumber,
354 IN ULONG SlotNumber,
355 IN ULONG Offset,
356 IN PVOID Buffer,
357 IN ULONG Length,
358 OUT PULONG ActualLength
359 );
360
361 NTSTATUS
362 NTAPI
363 KdpSysWriteBusData(
364 IN ULONG BusDataType,
365 IN ULONG BusNumber,
366 IN ULONG SlotNumber,
367 IN ULONG Offset,
368 IN PVOID Buffer,
369 IN ULONG Length,
370 OUT PULONG ActualLength
371 );
372
373 //
374 // Control Space
375 //
376 NTSTATUS
377 NTAPI
378 KdpSysReadControlSpace(
379 IN ULONG Processor,
380 IN ULONG64 BaseAddress,
381 IN PVOID Buffer,
382 IN ULONG Length,
383 OUT PULONG ActualLength
384 );
385
386 NTSTATUS
387 NTAPI
388 KdpSysWriteControlSpace(
389 IN ULONG Processor,
390 IN ULONG64 BaseAddress,
391 IN PVOID Buffer,
392 IN ULONG Length,
393 OUT PULONG ActualLength
394 );
395
396 //
397 // I/O Space
398 //
399 NTSTATUS
400 NTAPI
401 KdpSysReadIoSpace(
402 IN ULONG InterfaceType,
403 IN ULONG BusNumber,
404 IN ULONG AddressSpace,
405 IN ULONG64 IoAddress,
406 IN PVOID DataValue,
407 IN ULONG DataSize,
408 OUT PULONG ActualDataSize
409 );
410
411 NTSTATUS
412 NTAPI
413 KdpSysWriteIoSpace(
414 IN ULONG InterfaceType,
415 IN ULONG BusNumber,
416 IN ULONG AddressSpace,
417 IN ULONG64 IoAddress,
418 IN PVOID DataValue,
419 IN ULONG DataSize,
420 OUT PULONG ActualDataSize
421 );
422
423 //
424 // Low Memory
425 //
426 NTSTATUS
427 NTAPI
428 KdpSysCheckLowMemory(
429 IN ULONG Flags
430 );
431
432 //
433 // Internal routine for sending strings directly to the debugger
434 //
435 VOID
436 __cdecl
437 KdpDprintf(
438 IN PCHAR Format,
439 ...
440 );
441
442 //
443 // Global KD Data
444 //
445 extern DBGKD_GET_VERSION64 KdVersionBlock;
446 extern KDDEBUGGER_DATA64 KdDebuggerDataBlock;
447 extern LIST_ENTRY KdpDebuggerDataListHead;
448 extern KSPIN_LOCK KdpDataSpinLock;
449 extern LARGE_INTEGER KdPerformanceCounterRate;
450 extern LARGE_INTEGER KdTimerStart;
451 extern ULONG KdDisableCount;
452 extern KD_CONTEXT KdpContext;
453 extern PKDEBUG_ROUTINE KiDebugRoutine;
454 extern PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine;
455 extern BOOLEAN KdBreakAfterSymbolLoad;
456 extern BOOLEAN KdPitchDebugger;
457 extern BOOLEAN _KdDebuggerNotPresent;
458 extern BOOLEAN _KdDebuggerEnabled;
459 extern BOOLEAN KdAutoEnableOnEvent;
460 extern BOOLEAN KdBlockEnable;
461 extern BOOLEAN KdIgnoreUmExceptions;
462 extern BOOLEAN KdPreviouslyEnabled;
463 extern BOOLEAN KdpDebuggerStructuresInitialized;
464 extern BOOLEAN KdEnteredDebugger;
465 extern KDPC KdpTimeSlipDpc;
466 extern KTIMER KdpTimeSlipTimer;
467 extern WORK_QUEUE_ITEM KdpTimeSlipWorkItem;
468 extern LONG KdpTimeSlipPending;
469 extern PKEVENT KdpTimeSlipEvent;
470 extern KSPIN_LOCK KdpTimeSlipEventLock;
471 extern BOOLEAN KdpPortLocked;
472 extern BOOLEAN KdpControlCPressed;
473 extern KSPIN_LOCK KdpDebuggerLock;
474 extern LARGE_INTEGER KdTimerStop, KdTimerStart, KdTimerDifference;
475 extern ULONG KdComponentTableSize;
476 extern ULONG Kd_WIN2000_Mask;
477 extern PULONG KdComponentTable[104];
478 extern CHAR KdpMessageBuffer[4096], KdpPathBuffer[4096];
479 extern BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX];
480 extern KD_BREAKPOINT_TYPE KdpBreakpointInstruction;
481 extern BOOLEAN KdpOweBreakpoint;
482 extern BOOLEAN BreakpointsSuspended;
483 extern ULONG KdpNumInternalBreakpoints;
484 extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
485 extern ULONG TraceDataBuffer[40];
486 extern ULONG TraceDataBufferPosition;