xref: /reactos/ntoskrnl/kd/kd.h (revision 35180b3a)
1 #pragma once
2 
3 /* KD ROUTINES ***************************************************************/
4 
5 struct _KD_DISPATCH_TABLE;
6 
7 typedef
8 NTSTATUS
9 (NTAPI *PKDP_INIT_ROUTINE)(
10     _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
11     _In_ ULONG BootPhase);
12 
13 typedef
14 VOID
15 (NTAPI *PKDP_PRINT_ROUTINE)(
16     _In_ PCCH String,
17     _In_ ULONG Length);
18 
19 VOID
20 KdIoPuts(
21     _In_ PCSTR String);
22 
23 VOID
24 __cdecl
25 KdIoPrintf(
26     _In_ PCSTR Format,
27     ...);
28 
29 SIZE_T
30 KdIoReadLine(
31     _Out_ PCHAR Buffer,
32     _In_ SIZE_T Size);
33 
34 
35 /* INIT ROUTINES *************************************************************/
36 
37 KIRQL
38 NTAPI
39 KdbpAcquireLock(
40     _In_ PKSPIN_LOCK SpinLock);
41 
42 VOID
43 NTAPI
44 KdbpReleaseLock(
45     _In_ PKSPIN_LOCK SpinLock,
46     _In_ KIRQL OldIrql);
47 
48 VOID
49 KdpScreenAcquire(VOID);
50 
51 VOID
52 KdpScreenRelease(VOID);
53 
54 NTSTATUS
55 NTAPI
56 KdpScreenInit(
57     _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
58     _In_ ULONG BootPhase);
59 
60 NTSTATUS
61 NTAPI
62 KdpSerialInit(
63     _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
64     _In_ ULONG BootPhase);
65 
66 NTSTATUS
67 NTAPI
68 KdpDebugLogInit(
69     _In_ struct _KD_DISPATCH_TABLE *DispatchTable,
70     _In_ ULONG BootPhase);
71 
72 #ifdef KDBG
73 #define KdpKdbgInit KdbInitialize
74 #endif
75 
76 
77 /* KD GLOBALS ****************************************************************/
78 
79 /* Serial debug connection */
80 #define DEFAULT_DEBUG_PORT      2 /* COM2 */
81 #define DEFAULT_DEBUG_COM1_IRQ  4 /* COM1 IRQ */
82 #define DEFAULT_DEBUG_COM2_IRQ  3 /* COM2 IRQ */
83 #define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */
84 
85 /* KD Native Modes */
86 #define KdScreen    0
87 #define KdSerial    1
88 #define KdFile      2
89 #define KdKdbg      3
90 #define KdMax       4
91 
92 /* KD Private Debug Modes */
93 typedef struct _KDP_DEBUG_MODE
94 {
95     union
96     {
97         struct
98         {
99             /* Native Modes */
100             UCHAR Screen :1;
101             UCHAR Serial :1;
102             UCHAR File   :1;
103         };
104 
105         /* Generic Value */
106         ULONG Value;
107     };
108 } KDP_DEBUG_MODE;
109 
110 /* Dispatch Table for Wrapper Functions */
111 typedef struct _KD_DISPATCH_TABLE
112 {
113     LIST_ENTRY KdProvidersList;
114     PKDP_INIT_ROUTINE KdpInitRoutine;
115     PKDP_PRINT_ROUTINE KdpPrintRoutine;
116     NTSTATUS InitStatus;
117 } KD_DISPATCH_TABLE, *PKD_DISPATCH_TABLE;
118 
119 /* The current Debugging Mode */
120 extern KDP_DEBUG_MODE KdpDebugMode;
121 
122 /* Port Information for the Serial Native Mode */
123 extern ULONG  SerialPortNumber;
124 extern CPPORT SerialPortInfo;
125 
126 /* Logging file path */
127 extern ANSI_STRING KdpLogFileName;
128 
129 /* Init Functions for Native Providers */
130 extern PKDP_INIT_ROUTINE InitRoutines[KdMax];
131 
132 /* Dispatch Tables for Native Providers */
133 extern KD_DISPATCH_TABLE DispatchTable[KdMax];
134 
135 /* The KD Native Provider List */
136 extern LIST_ENTRY KdProviders;
137