213c83219a19334eb81aa4baee28bb2dbf737e74
[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 // Multi-Processor Switch Support
76 //
77 BOOLEAN
78 NTAPI
79 KdpSwitchProcessor(
80 IN PEXCEPTION_RECORD ExceptionRecord,
81 IN OUT PCONTEXT ContextRecord,
82 IN BOOLEAN SecondChanceException
83 );
84
85 //
86 // Time Slip Support
87 //
88 VOID
89 NTAPI
90 KdpTimeSlipWork(
91 IN PVOID Context
92 );
93
94 VOID
95 NTAPI
96 KdpTimeSlipDpcRoutine(
97 IN PKDPC Dpc,
98 IN PVOID DeferredContext,
99 IN PVOID SystemArgument1,
100 IN PVOID SystemArgument2
101 );
102
103 //
104 // Debug Trap Handlers
105 //
106 BOOLEAN
107 NTAPI
108 KdpStub(
109 IN PKTRAP_FRAME TrapFrame,
110 IN PKEXCEPTION_FRAME ExceptionFrame,
111 IN PEXCEPTION_RECORD ExceptionRecord,
112 IN PCONTEXT ContextRecord,
113 IN KPROCESSOR_MODE PreviousMode,
114 IN BOOLEAN SecondChanceException
115 );
116
117 BOOLEAN
118 NTAPI
119 KdpTrap(
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 //
129 // Port Locking
130 //
131 VOID
132 NTAPI
133 KdpPortLock(
134 VOID
135 );
136
137 VOID
138 NTAPI
139 KdpPortUnlock(
140 VOID
141 );
142
143 BOOLEAN
144 NTAPI
145 KdpPollBreakInWithPortLock(
146 VOID
147 );
148
149 //
150 // Debugger Enable, Enter and Exit
151 //
152 BOOLEAN
153 NTAPI
154 KdEnterDebugger(
155 IN PKTRAP_FRAME TrapFrame,
156 IN PKEXCEPTION_FRAME ExceptionFrame
157 );
158
159 VOID
160 NTAPI
161 KdExitDebugger(
162 IN BOOLEAN Entered
163 );
164
165 NTSTATUS
166 NTAPI
167 KdEnableDebuggerWithLock(
168 IN BOOLEAN NeedLock
169 );
170
171 //
172 // Debug Event Handlers
173 //
174 NTSTATUS
175 NTAPI
176 KdpPrint(
177 IN ULONG ComponentId,
178 IN ULONG ComponentMask,
179 IN LPSTR String,
180 IN USHORT Length,
181 IN KPROCESSOR_MODE PreviousMode,
182 IN PKTRAP_FRAME TrapFrame,
183 IN PKEXCEPTION_FRAME ExceptionFrame,
184 OUT PBOOLEAN Status
185 );
186
187 BOOLEAN
188 NTAPI
189 KdpPrompt(
190 IN LPSTR InString,
191 IN USHORT InStringLength,
192 OUT LPSTR OutString,
193 IN USHORT OutStringLength,
194 IN KPROCESSOR_MODE PreviousMode,
195 IN PKTRAP_FRAME TrapFrame,
196 IN PKEXCEPTION_FRAME ExceptionFrame
197 );
198
199 VOID
200 NTAPI
201 KdpSymbol(
202 IN PSTRING DllPath,
203 IN PKD_SYMBOLS_INFO DllBase,
204 IN BOOLEAN Unload,
205 IN KPROCESSOR_MODE PreviousMode,
206 IN PCONTEXT ContextRecord,
207 IN PKTRAP_FRAME TrapFrame,
208 IN PKEXCEPTION_FRAME ExceptionFrame
209 );
210
211 VOID
212 NTAPI
213 KdpCommandString(
214 IN ULONG Length,
215 IN LPSTR String,
216 IN KPROCESSOR_MODE PreviousMode,
217 IN PCONTEXT ContextRecord,
218 IN PKTRAP_FRAME TrapFrame,
219 IN PKEXCEPTION_FRAME ExceptionFrame
220 );
221
222 //
223 // State Change Notifications
224 //
225 BOOLEAN
226 NTAPI
227 KdpReportLoadSymbolsStateChange(
228 IN PSTRING PathName,
229 IN PKD_SYMBOLS_INFO SymbolInfo,
230 IN BOOLEAN Unload,
231 IN OUT PCONTEXT Context
232 );
233
234 BOOLEAN
235 NTAPI
236 KdpReportExceptionStateChange(
237 IN PEXCEPTION_RECORD ExceptionRecord,
238 IN OUT PCONTEXT Context,
239 IN BOOLEAN SecondChanceException
240 );
241
242 //
243 // Breakpoint Support
244 //
245 VOID
246 NTAPI
247 KdpRestoreAllBreakpoints(
248 VOID
249 );
250
251 BOOLEAN
252 NTAPI
253 KdpDeleteBreakpoint(
254 IN ULONG BpEntry
255 );
256
257 BOOLEAN
258 NTAPI
259 KdpDeleteBreakpointRange(
260 IN PVOID Base,
261 IN PVOID Limit
262 );
263
264 ULONG
265 NTAPI
266 KdpAddBreakpoint(
267 IN PVOID Address
268 );
269
270 //
271 // Architecture dependent support routines
272 //
273
274 //
275 // Version
276 //
277 VOID
278 NTAPI
279 KdpSysGetVersion(
280 IN PDBGKD_GET_VERSION64 Version
281 );
282
283 //
284 // Context
285 //
286 VOID
287 NTAPI
288 KdpGetStateChange(
289 IN PDBGKD_MANIPULATE_STATE64 State,
290 IN PCONTEXT Context
291 );
292
293 VOID
294 NTAPI
295 KdpSetContextState(
296 IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
297 IN PCONTEXT Context
298 );
299
300 //
301 // MSR
302 //
303 NTSTATUS
304 NTAPI
305 KdpSysReadMsr(
306 IN ULONG Msr,
307 OUT PLARGE_INTEGER MsrValue
308 );
309
310 NTSTATUS
311 NTAPI
312 KdpSysWriteMsr(
313 IN ULONG Msr,
314 IN PLARGE_INTEGER MsrValue
315 );
316
317 //
318 // Bus
319 //
320 NTSTATUS
321 NTAPI
322 KdpSysReadBusData(
323 IN ULONG BusDataType,
324 IN ULONG BusNumber,
325 IN ULONG SlotNumber,
326 IN PVOID Buffer,
327 IN ULONG Offset,
328 IN ULONG Length,
329 OUT PULONG ActualLength
330 );
331
332 NTSTATUS
333 NTAPI
334 KdpSysWriteBusData(
335 IN ULONG BusDataType,
336 IN ULONG BusNumber,
337 IN ULONG SlotNumber,
338 IN PVOID Buffer,
339 IN ULONG Offset,
340 IN ULONG Length,
341 OUT PULONG ActualLength
342 );
343
344 //
345 // Control Space
346 //
347 NTSTATUS
348 NTAPI
349 KdpSysReadControlSpace(
350 IN ULONG Processor,
351 IN ULONG64 BaseAddress,
352 IN PVOID Buffer,
353 IN ULONG Length,
354 OUT PULONG ActualLength
355 );
356
357 NTSTATUS
358 NTAPI
359 KdpSysWriteControlSpace(
360 IN ULONG Processor,
361 IN ULONG64 BaseAddress,
362 IN PVOID Buffer,
363 IN ULONG Length,
364 OUT PULONG ActualLength
365 );
366
367 //
368 // I/O Space
369 //
370 NTSTATUS
371 NTAPI
372 KdpSysReadIoSpace(
373 IN ULONG InterfaceType,
374 IN ULONG BusNumber,
375 IN ULONG AddressSpace,
376 IN ULONG64 IoAddress,
377 IN PVOID DataValue,
378 IN ULONG DataSize,
379 OUT PULONG ActualDataSize
380 );
381
382 NTSTATUS
383 NTAPI
384 KdpSysWriteIoSpace(
385 IN ULONG InterfaceType,
386 IN ULONG BusNumber,
387 IN ULONG AddressSpace,
388 IN ULONG64 IoAddress,
389 IN PVOID DataValue,
390 IN ULONG DataSize,
391 OUT PULONG ActualDataSize
392 );
393
394 //
395 // Low Memory
396 //
397 NTSTATUS
398 NTAPI
399 KdpSysCheckLowMemory(
400 IN ULONG Flags
401 );
402
403 //
404 // Internal routine for sending strings directly to the debugger
405 //
406 VOID
407 __cdecl
408 KdpDprintf(
409 IN PCHAR Format,
410 ...
411 );
412
413 //
414 // Global KD Data
415 //
416 extern DBGKD_GET_VERSION64 KdVersionBlock;
417 extern KDDEBUGGER_DATA64 KdDebuggerDataBlock;
418 extern LIST_ENTRY KdpDebuggerDataListHead;
419 extern KSPIN_LOCK KdpDataSpinLock;
420 extern LARGE_INTEGER KdPerformanceCounterRate;
421 extern LARGE_INTEGER KdTimerStart;
422 extern ULONG KdDisableCount;
423 extern KD_CONTEXT KdpContext;
424 extern PKDEBUG_ROUTINE KiDebugRoutine;
425 extern PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine;
426 extern BOOLEAN KdBreakAfterSymbolLoad;
427 extern BOOLEAN KdPitchDebugger;
428 extern BOOLEAN _KdDebuggerNotPresent;
429 extern BOOLEAN _KdDebuggerEnabled;
430 extern BOOLEAN KdAutoEnableOnEvent;
431 extern BOOLEAN KdPreviouslyEnabled;
432 extern BOOLEAN KdpDebuggerStructuresInitialized;
433 extern BOOLEAN KdEnteredDebugger;
434 extern KDPC KdpTimeSlipDpc;
435 extern KTIMER KdpTimeSlipTimer;
436 extern WORK_QUEUE_ITEM KdpTimeSlipWorkItem;
437 extern LONG KdpTimeSlipPending;
438 extern PKEVENT KdpTimeSlipEvent;
439 extern KSPIN_LOCK KdpTimeSlipEventLock;
440 extern BOOLEAN KdpPortLocked;
441 extern BOOLEAN KdpControlCPressed;
442 extern KSPIN_LOCK KdpDebuggerLock;
443 extern LARGE_INTEGER KdTimerStop, KdTimerStart, KdTimerDifference;
444 extern ULONG KdComponentTableSize;
445 extern ULONG Kd_WIN2000_Mask;
446 extern PULONG KdComponentTable[104];
447 extern CHAR KdpMessageBuffer[4096], KdpPathBuffer[4096];
448 extern BREAKPOINT_ENTRY KdpBreakpointTable[KD_BREAKPOINT_MAX];
449 extern KD_BREAKPOINT_TYPE KdpBreakpointInstruction;
450 extern BOOLEAN KdpOweBreakpoint;
451 extern BOOLEAN BreakpointsSuspended;
452 extern ULONG KdpNumInternalBreakpoints;
453 extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
454 extern ULONG TraceDataBuffer[40];
455 extern ULONG TraceDataBufferPosition;