73dff9b8a8ed76ba61203cd51f9c29e41e1757e1
[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 // Breakpoint Status Flags
11 //
12 typedef enum _KDP_BREAKPOINT_FLAGS
13 {
14 KdpBreakpointActive = 1,
15 KdpBreakpointPending = 2,
16 KdpBreakpointSuspended = 4,
17 KdpBreakpointExpired = 8
18 } KDP_BREAKPOINT_FLAGS;
19
20 //
21 // Structure for Breakpoints
22 //
23 typedef struct _BREAKPOINT_ENTRY
24 {
25 ULONG Flags;
26 PKPROCESS Process;
27 PVOID Address;
28 UCHAR Content;
29 } BREAKPOINT_ENTRY, *PBREAKPOINT_ENTRY;
30
31 //
32 // Debug and Multi-Processor Switch Routine Definitions
33 //
34 typedef
35 BOOLEAN
36 (NTAPI *PKDEBUG_ROUTINE)(
37 IN PKTRAP_FRAME TrapFrame,
38 IN PKEXCEPTION_FRAME ExceptionFrame,
39 IN PEXCEPTION_RECORD ExceptionRecord,
40 IN PCONTEXT Context,
41 IN KPROCESSOR_MODE PreviousMode,
42 IN BOOLEAN SecondChance
43 );
44
45 typedef
46 BOOLEAN
47 (NTAPI *PKDEBUG_SWITCH_ROUTINE)(
48 IN PEXCEPTION_RECORD ExceptionRecord,
49 IN PCONTEXT Context,
50 IN BOOLEAN SecondChance
51 );
52
53 //
54 // Initialization Routines
55 //
56 BOOLEAN
57 NTAPI
58 KdInitSystem(
59 ULONG Reserved,
60 PLOADER_PARAMETER_BLOCK LoaderBlock
61 );
62
63 VOID
64 NTAPI
65 KdUpdateDataBlock(
66 VOID
67 );
68
69 //
70 // Multi-Processor Switch Support
71 //
72 BOOLEAN
73 NTAPI
74 KdpSwitchProcessor(
75 IN PEXCEPTION_RECORD ExceptionRecord,
76 IN OUT PCONTEXT ContextRecord,
77 IN BOOLEAN SecondChanceException
78 );
79
80 //
81 // Time Slip Support
82 //
83 VOID
84 NTAPI
85 KdpTimeSlipWork(
86 IN PVOID Context
87 );
88
89 VOID
90 NTAPI
91 KdpTimeSlipDpcRoutine(
92 IN PKDPC Dpc,
93 IN PVOID DeferredContext,
94 IN PVOID SystemArgument1,
95 IN PVOID SystemArgument2
96 );
97
98 //
99 // Debug Trap Handlers
100 //
101 BOOLEAN
102 NTAPI
103 KdpStub(
104 IN PKTRAP_FRAME TrapFrame,
105 IN PKEXCEPTION_FRAME ExceptionFrame,
106 IN PEXCEPTION_RECORD ExceptionRecord,
107 IN PCONTEXT ContextRecord,
108 IN KPROCESSOR_MODE PreviousMode,
109 IN BOOLEAN SecondChanceException
110 );
111
112 BOOLEAN
113 NTAPI
114 KdpTrap(
115 IN PKTRAP_FRAME TrapFrame,
116 IN PKEXCEPTION_FRAME ExceptionFrame,
117 IN PEXCEPTION_RECORD ExceptionRecord,
118 IN PCONTEXT ContextRecord,
119 IN KPROCESSOR_MODE PreviousMode,
120 IN BOOLEAN SecondChanceException
121 );
122
123 //
124 // Port Locking
125 //
126 VOID
127 NTAPI
128 KdpPortLock(
129 VOID
130 );
131
132 VOID
133 NTAPI
134 KdpPortUnlock(
135 VOID
136 );
137
138 BOOLEAN
139 NTAPI
140 KdpPollBreakInWithPortLock(
141 VOID
142 );
143
144 //
145 // Debugger Enable, Enter and Exit
146 //
147 BOOLEAN
148 NTAPI
149 KdEnterDebugger(
150 IN PKTRAP_FRAME TrapFrame,
151 IN PKEXCEPTION_FRAME ExceptionFrame
152 );
153
154 VOID
155 NTAPI
156 KdExitDebugger(
157 IN BOOLEAN Entered
158 );
159
160 NTSTATUS
161 NTAPI
162 KdEnableDebuggerWithLock(
163 IN BOOLEAN NeedLock
164 );
165
166 //
167 // Debug Event Handlers
168 //
169 NTSTATUS
170 NTAPI
171 KdpPrint(
172 IN ULONG ComponentId,
173 IN ULONG ComponentMask,
174 IN LPSTR String,
175 IN USHORT Length,
176 IN KPROCESSOR_MODE PreviousMode,
177 IN PKTRAP_FRAME TrapFrame,
178 IN PKEXCEPTION_FRAME ExceptionFrame,
179 OUT PBOOLEAN Status
180 );
181
182 BOOLEAN
183 NTAPI
184 KdpPrompt(
185 IN LPSTR InString,
186 IN USHORT InStringLength,
187 OUT LPSTR OutString,
188 IN USHORT OutStringLength,
189 IN KPROCESSOR_MODE PreviousMode,
190 IN PKTRAP_FRAME TrapFrame,
191 IN PKEXCEPTION_FRAME ExceptionFrame
192 );
193
194 VOID
195 NTAPI
196 KdpSymbol(
197 IN PSTRING DllPath,
198 IN PKD_SYMBOLS_INFO DllBase,
199 IN BOOLEAN Unload,
200 IN KPROCESSOR_MODE PreviousMode,
201 IN PCONTEXT ContextRecord,
202 IN PKTRAP_FRAME TrapFrame,
203 IN PKEXCEPTION_FRAME ExceptionFrame
204 );
205
206 VOID
207 NTAPI
208 KdpCommandString(
209 IN ULONG Length,
210 IN LPSTR String,
211 IN KPROCESSOR_MODE PreviousMode,
212 IN PCONTEXT ContextRecord,
213 IN PKTRAP_FRAME TrapFrame,
214 IN PKEXCEPTION_FRAME ExceptionFrame
215 );
216
217 //
218 // State Change Notifications
219 //
220 BOOLEAN
221 NTAPI
222 KdpReportLoadSymbolsStateChange(
223 IN PSTRING PathName,
224 IN PKD_SYMBOLS_INFO SymbolInfo,
225 IN BOOLEAN Unload,
226 IN OUT PCONTEXT Context
227 );
228
229 BOOLEAN
230 NTAPI
231 KdpReportExceptionStateChange(
232 IN PEXCEPTION_RECORD ExceptionRecord,
233 IN OUT PCONTEXT Context,
234 IN BOOLEAN SecondChanceException
235 );
236
237 //
238 // Breakpoint Support
239 //
240 VOID
241 NTAPI
242 KdpRestoreAllBreakpoints(
243 VOID
244 );
245
246 BOOLEAN
247 NTAPI
248 KdpDeleteBreakpoint(
249 IN ULONG BpEntry
250 );
251
252 BOOLEAN
253 NTAPI
254 KdpDeleteBreakpointRange(
255 IN PVOID Base,
256 IN PVOID Limit
257 );
258
259 ULONG
260 NTAPI
261 KdpAddBreakpoint(
262 IN PVOID Address
263 );
264
265 //
266 // Internal routine for sending strings directly to the debugger
267 //
268 VOID
269 __cdecl
270 KdpDprintf(
271 IN PCHAR Format,
272 ...
273 );
274
275 //
276 // Global KD Data
277 //
278 extern DBGKD_GET_VERSION64 KdVersionBlock;
279 extern KDDEBUGGER_DATA64 KdDebuggerDataBlock;
280 extern LIST_ENTRY KdpDebuggerDataListHead;
281 extern KSPIN_LOCK KdpDataSpinLock;
282 extern LARGE_INTEGER KdPerformanceCounterRate;
283 extern LARGE_INTEGER KdTimerStart;
284 extern ULONG KdDisableCount;
285 extern KD_CONTEXT KdpContext;
286 extern PKDEBUG_ROUTINE KiDebugRoutine;
287 extern PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine;
288 extern BOOLEAN KdBreakAfterSymbolLoad;
289 extern BOOLEAN KdPitchDebugger;
290 extern BOOLEAN _KdDebuggerNotPresent;
291 extern BOOLEAN _KdDebuggerEnabled;
292 extern BOOLEAN KdAutoEnableOnEvent;
293 extern BOOLEAN KdPreviouslyEnabled;
294 extern BOOLEAN KdpDebuggerStructuresInitialized;
295 extern BOOLEAN KdEnteredDebugger;
296 extern KDPC KdpTimeSlipDpc;
297 extern KTIMER KdpTimeSlipTimer;
298 extern WORK_QUEUE_ITEM KdpTimeSlipWorkItem;
299 extern LONG KdpTimeSlipPending;
300 extern PKEVENT KdpTimeSlipEvent;
301 extern KSPIN_LOCK KdpTimeSlipEventLock;
302 extern BOOLEAN KdpPortLocked;
303 extern BOOLEAN KdpControlCPressed;
304 extern KSPIN_LOCK KdpDebuggerLock;
305 extern LARGE_INTEGER KdTimerStop, KdTimerStart, KdTimerDifference;
306 extern ULONG KdComponentTableSize;
307 extern ULONG Kd_WIN2000_Mask;
308 extern PULONG KdComponentTable[104];
309 extern CHAR KdpMessageBuffer[4096], KdpPathBuffer[4096];
310 extern BREAKPOINT_ENTRY KdpBreakpointTable[20];
311 extern ULONG KdpBreakpointInstruction;
312 extern BOOLEAN KdpOweBreakpoint;
313 extern BOOLEAN BreakpointsSuspended;
314 extern ULONG KdpNumInternalBreakpoints;
315 extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
316 extern ULONG TraceDataBuffer[40];
317 extern ULONG TraceDataBufferPosition;