Make winkd somewhat portable.
[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 //
64 // Debug and Multi-Processor Switch Routines
65 //
66 BOOLEAN
67 NTAPI
68 KdpEnterDebuggerException(
69 IN PKTRAP_FRAME TrapFrame,
70 IN PKEXCEPTION_FRAME ExceptionFrame,
71 IN PEXCEPTION_RECORD ExceptionRecord,
72 IN PCONTEXT Context,
73 IN KPROCESSOR_MODE PreviousMode,
74 IN BOOLEAN SecondChance
75 );
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 ULONG
175 NTAPI
176 KdpPrint(
177 IN ULONG ComponentId,
178 IN ULONG ComponentMask,
179 IN LPSTR String,
180 IN ULONG Length,
181 IN KPROCESSOR_MODE PreviousMode,
182 IN PKTRAP_FRAME TrapFrame,
183 IN PKEXCEPTION_FRAME ExceptionFrame,
184 OUT PBOOLEAN Status
185 );
186
187 ULONG
188 NTAPI
189 KdpSymbol(
190 IN PSTRING DllPath,
191 IN PKD_SYMBOLS_INFO DllBase,
192 IN BOOLEAN Unload,
193 IN KPROCESSOR_MODE PreviousMode,
194 IN PCONTEXT ContextRecord,
195 IN PKTRAP_FRAME TrapFrame,
196 IN PKEXCEPTION_FRAME ExceptionFrame
197 );
198
199 //
200 // State Change Notifications
201 //
202 BOOLEAN
203 NTAPI
204 KdpReportLoadSymbolsStateChange(
205 IN PSTRING PathName,
206 IN PKD_SYMBOLS_INFO SymbolInfo,
207 IN BOOLEAN Unload,
208 IN OUT PCONTEXT Context
209 );
210
211 BOOLEAN
212 NTAPI
213 KdpReportExceptionStateChange(
214 IN PEXCEPTION_RECORD ExceptionRecord,
215 IN OUT PCONTEXT Context,
216 IN BOOLEAN SecondChanceException
217 );
218
219 //
220 // Breakpoint Support
221 //
222 VOID
223 NTAPI
224 KdpRestoreAllBreakpoints(
225 VOID
226 );
227
228 BOOLEAN
229 NTAPI
230 KdpDeleteBreakpoint(
231 IN ULONG BpEntry
232 );
233
234 BOOLEAN
235 NTAPI
236 KdpDeleteBreakpointRange(
237 IN PVOID Base,
238 IN PVOID Limit
239 );
240
241 ULONG
242 NTAPI
243 KdpAddBreakpoint(
244 IN PVOID Address
245 );
246
247 VOID
248 NTAPI
249 KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
250 IN PCONTEXT Context);
251
252 BOOLEAN
253 NTAPI
254 KdpReport(IN PKTRAP_FRAME TrapFrame,
255 IN PKEXCEPTION_FRAME ExceptionFrame,
256 IN PEXCEPTION_RECORD ExceptionRecord,
257 IN PCONTEXT ContextRecord,
258 IN KPROCESSOR_MODE PreviousMode,
259 IN BOOLEAN SecondChanceException);
260
261 //
262 // Global KD Data
263 //
264 extern DBGKD_GET_VERSION64 KdVersionBlock;
265 extern KDDEBUGGER_DATA64 KdDebuggerDataBlock;
266 extern LIST_ENTRY KdpDebuggerDataListHead;
267 extern KSPIN_LOCK KdpDataSpinLock;
268 extern LARGE_INTEGER KdPerformanceCounterRate;
269 extern LARGE_INTEGER KdTimerStart;
270 extern ULONG KdDisableCount;
271 extern KD_CONTEXT KdpContext;
272 extern PKDEBUG_ROUTINE KiDebugRoutine;
273 extern PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine;
274 extern BOOLEAN KdBreakAfterSymbolLoad;
275 extern BOOLEAN KdPitchDebugger;
276 extern BOOLEAN _KdDebuggerNotPresent;
277 extern BOOLEAN _KdDebuggerEnabled;
278 extern BOOLEAN KdAutoEnableOnEvent;
279 extern BOOLEAN KdPreviouslyEnabled;
280 extern BOOLEAN KdpDebuggerStructuresInitialized;
281 extern BOOLEAN KdEnteredDebugger;
282 extern KDPC KdpTimeSlipDpc;
283 extern KTIMER KdpTimeSlipTimer;
284 extern WORK_QUEUE_ITEM KdpTimeSlipWorkItem;
285 extern LONG KdpTimeSlipPending;
286 extern PKEVENT KdpTimeSlipEvent;
287 extern KSPIN_LOCK KdpTimeSlipEventLock;
288 extern BOOLEAN KdpPortLocked;
289 extern BOOLEAN KdpControlCPressed;
290 extern KSPIN_LOCK KdpDebuggerLock;
291 extern LARGE_INTEGER KdTimerStop, KdTimerStart, KdTimerDifference;
292 extern ULONG KdComponentTableSize;
293 extern ULONG Kd_WIN2000_Mask;
294 extern PULONG KdComponentTable[104];
295 extern CHAR KdpMessageBuffer[4096], KdpPathBuffer[4096];
296 extern BREAKPOINT_ENTRY KdpBreakpointTable[20];
297 extern ULONG KdpBreakpointInstruction;
298 extern BOOLEAN KdpOweBreakpoint;
299 extern BOOLEAN BreakpointsSuspended;
300 extern ULONG KdpNumInternalBreakpoints;
301 extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
302 extern ULONG TraceDataBuffer[40];
303 extern ULONG TraceDataBufferPosition;