[KSECDD]
[reactos.git] / reactos / drivers / base / kdgdb / kdgdb.h
1 /*
2 * COPYRIGHT: GPL, see COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/base/kddll/kddll.h
5 * PURPOSE: Base definitions for the kernel debugger.
6 */
7
8 #ifndef _KDGDB_H_
9 #define _KDGDB_H_
10
11 #define NOEXTAPI
12 #include <ntifs.h>
13 #include <halfuncs.h>
14 #include <stdio.h>
15 #include <arc/arc.h>
16 #include <windbgkd.h>
17 #include <kddll.h>
18
19 #define KDDEBUG /* uncomment to enable debugging this dll */
20
21 #ifndef KDDEBUG
22 #define KDDBGPRINT(...)
23 #else
24 extern ULONG KdpDbgPrint(const char* Format, ...);
25 #define KDDBGPRINT KdpDbgPrint
26 #endif
27
28 /* Callbacks to simulate a KdReceive <-> KdSend loop without GDB being aware of it */
29 typedef VOID (*KDP_SEND_HANDLER)(
30 _In_ ULONG PacketType,
31 _In_ PSTRING MessageHeader,
32 _In_ PSTRING MessageData
33 );
34 typedef KDSTATUS (*KDP_MANIPULATESTATE_HANDLER)(
35 _Out_ DBGKD_MANIPULATE_STATE64* State,
36 _Out_ PSTRING MessageData,
37 _Out_ PULONG MessageLength,
38 _Inout_ PKD_CONTEXT KdContext
39 );
40
41 /* gdb_input.c */
42 extern HANDLE gdb_dbg_thread;
43 KDSTATUS gdb_interpret_input(_Out_ DBGKD_MANIPULATE_STATE64* State, _Out_ PSTRING MessageData, _Out_ PULONG MessageLength, _Inout_ PKD_CONTEXT KdContext);
44
45 /* gdb_receive.c */
46 extern CHAR gdb_input[];
47 KDSTATUS NTAPI gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext);
48 char hex_value(char ch);
49
50 /* gdb_send.c */
51 void send_gdb_packet(_In_ CHAR* Buffer);
52 void send_gdb_memory(_In_ VOID* Buffer, size_t Length);
53 void gdb_send_debug_io(_In_ PSTRING String);
54 void gdb_send_exception(void);
55 void send_gdb_ntstatus(_In_ NTSTATUS Status);
56
57 /* kdcom.c */
58 KDSTATUS NTAPI KdpPollBreakIn(VOID);
59 VOID NTAPI KdpSendByte(_In_ UCHAR Byte);
60 KDSTATUS NTAPI KdpReceiveByte(_Out_ PUCHAR OutByte);
61
62 /* kdpacket.c */
63 extern DBGKD_ANY_WAIT_STATE_CHANGE CurrentStateChange;
64 extern DBGKD_GET_VERSION64 KdVersion;
65 extern KDDEBUGGER_DATA64* KdDebuggerDataBlock;
66 extern KDP_SEND_HANDLER KdpSendPacketHandler;
67 extern KDP_MANIPULATESTATE_HANDLER KdpManipulateStateHandler;
68
69
70 /* arch_sup.c */
71 void gdb_send_registers(void);
72
73 /* Architecture specific defines. See ntoskrnl/include/internal/arch/ke.h */
74 #ifdef _M_IX86
75 # define KdpGetContextPc(Context) \
76 ((Context)->Eip)
77 # define KdpSetContextPc(Context, ProgramCounter) \
78 ((Context)->Eip = (ProgramCounter))
79 # define KD_BREAKPOINT_SIZE sizeof(UCHAR)
80 #else
81 # error "Please define relevant macros for your architecture"
82 #endif
83
84 #endif /* _KDGDB_H_ */