ReactOS  0.4.15-dev-2945-g7100a24
kdio.c File Reference
#include <ntoskrnl.h>
#include <reactos/buildno.h>
#include <debug.h>
Include dependency graph for kdio.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define KdpBufferSize   (1024 * 512)
 
#define KdpScreenLineLengthDefault   80
 

Functions

KIRQL NTAPI KdpAcquireLock (IN PKSPIN_LOCK SpinLock)
 
VOID NTAPI KdpReleaseLock (IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
 
static VOID NTAPI KdpLoggerThread (PVOID Context)
 
static VOID NTAPI KdpPrintToLogFile (PCHAR String, ULONG StringLength)
 
VOID NTAPI KdpDebugLogInit (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 
VOID NTAPI KdpSerialDebugPrint (PCHAR Message, ULONG Length)
 
VOID NTAPI KdpSerialInit (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 
VOID KdpScreenAcquire (VOID)
 
VOID KdpScreenRelease (VOID)
 
static VOID NTAPI KdpScreenPrint (PCHAR Message, ULONG Length)
 
VOID NTAPI KdpScreenInit (PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
 
BOOLEAN NTAPI KdpPrintString (_In_ PSTRING Output)
 
VOID NTAPI KdSendPacket (IN ULONG PacketType, IN PSTRING MessageHeader, IN PSTRING MessageData, IN OUT PKD_CONTEXT Context)
 
KDSTATUS NTAPI KdReceivePacket (IN ULONG PacketType, OUT PSTRING MessageHeader, OUT PSTRING MessageData, OUT PULONG DataLength, IN OUT PKD_CONTEXT Context)
 

Variables

static BOOLEAN KdpLoggingEnabled = FALSE
 
static BOOLEAN KdpLoggingStarting = FALSE
 
static PCHAR KdpDebugBuffer = NULL
 
static volatile ULONG KdpCurrentPosition = 0
 
static volatile ULONG KdpFreeBytes = 0
 
static KSPIN_LOCK KdpDebugLogSpinLock
 
static KEVENT KdpLoggerThreadEvent
 
static HANDLE KdpLogFileHandle
 
ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log")
 
ULONG ExpInitializationPhase
 
static KSPIN_LOCK KdpSerialSpinLock
 
ULONG SerialPortNumber = DEFAULT_DEBUG_PORT
 
CPPORT SerialPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0}
 
static CHAR KdpScreenLineBuffer [KdpScreenLineLengthDefault+1] = ""
 
static ULONG KdpScreenLineBufferPos = 0
 
static ULONG KdpScreenLineLength = 0
 
const ULONG KdpDmesgBufferSize = 128 * 1024
 
PCHAR KdpDmesgBuffer = NULL
 
volatile ULONG KdpDmesgCurrentPosition = 0
 
volatile ULONG KdpDmesgFreeBytes = 0
 
volatile ULONG KdbDmesgTotalWritten = 0
 
volatile BOOLEAN KdbpIsInDmesgMode = FALSE
 
static KSPIN_LOCK KdpDmesgLogSpinLock
 
KDP_DEBUG_MODE KdpDebugMode
 
LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}
 
KD_DISPATCH_TABLE DispatchTable [KdMax]
 
PKDP_INIT_ROUTINE InitRoutines [KdMax]
 
static ULONG KdbgNextApiNumber = DbgKdContinueApi
 
static CONTEXT KdbgContext
 
static EXCEPTION_RECORD64 KdbgExceptionRecord
 
static BOOLEAN KdbgFirstChanceException
 
static NTSTATUS KdbgContinueStatus = STATUS_SUCCESS
 
STRING KdbPromptString
 

Macro Definition Documentation

◆ KdpBufferSize

#define KdpBufferSize   (1024 * 512)

Definition at line 20 of file kdio.c.

◆ KdpScreenLineLengthDefault

#define KdpScreenLineLengthDefault   80

Definition at line 36 of file kdio.c.

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file kdio.c.

Function Documentation

◆ KdpAcquireLock()

KIRQL NTAPI KdpAcquireLock ( IN PKSPIN_LOCK  SpinLock)

Definition at line 67 of file kdio.c.

68 {
69  KIRQL OldIrql;
70 
71  /* Acquire the spinlock without waiting at raised IRQL */
72  while (TRUE)
73  {
74  /* Loop until the spinlock becomes available */
75  while (!KeTestSpinLock(SpinLock));
76 
77  /* Spinlock is free, raise IRQL to high level */
79 
80  /* Try to get the spinlock */
82  break;
83 
84  /* Someone else got the spinlock, lower IRQL back */
86  }
87 
88  return OldIrql;
89 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define TRUE
Definition: types.h:120
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
BOOLEAN FASTCALL KeTestSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:475
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
BOOLEAN FASTCALL KeTryToAcquireSpinLockAtDpcLevel(IN OUT PKSPIN_LOCK SpinLock)
Definition: spinlock.c:309

Referenced by KdpPrintToLogFile(), KdpScreenPrint(), KdpSerialDebugPrint(), and KdReceivePacket().

◆ KdpDebugLogInit()

VOID NTAPI KdpDebugLogInit ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Definition at line 211 of file kdio.c.

213 {
218  HANDLE ThreadHandle;
220 
221  if (!KdpDebugMode.File) return;
222 
223  if (BootPhase == 0)
224  {
226 
227  /* Write out the functions that we support for now */
228  DispatchTable->KdpInitRoutine = KdpDebugLogInit;
229  DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
230 
231  /* Register as a Provider */
232  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
233  }
234  else if (BootPhase == 1)
235  {
236  /* Allocate a buffer for debug log */
239 
240  /* Initialize spinlock */
242 
243  HalDisplayString("\r\n File log debugging enabled\r\n\r\n");
244  }
245  else if (BootPhase == 3)
246  {
247  /* Setup the log name */
249  if (!NT_SUCCESS(Status)) return;
250 
252  &FileName,
254  NULL,
255  NULL);
256 
257  /* Create the log file */
258  Status = ZwCreateFile(&KdpLogFileHandle,
261  &Iosb,
262  NULL,
267  NULL,
268  0);
269 
271 
272  if (!NT_SUCCESS(Status))
273  {
274  DPRINT1("Failed to open log file: 0x%08x\n", Status);
275  return;
276  }
277 
279 
280  /* Create the logger thread */
281  Status = PsCreateSystemThread(&ThreadHandle,
283  NULL,
284  NULL,
285  NULL,
287  NULL);
288  if (!NT_SUCCESS(Status))
289  {
291  return;
292  }
293 
294  Priority = 7;
295  ZwSetInformationThread(ThreadHandle,
297  &Priority,
298  sizeof(Priority));
299 
300  ZwClose(ThreadHandle);
301  }
302 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
static HANDLE KdpLogFileHandle
Definition: kdio.c:28
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static volatile ULONG KdpFreeBytes
Definition: kdio.c:25
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
LONG KPRIORITY
Definition: compat.h:662
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:27
#define FILE_SHARE_READ
Definition: compat.h:136
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:26
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
static VOID NTAPI KdpPrintToLogFile(PCHAR String, ULONG StringLength)
Definition: kdio.c:157
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
ANSI_STRING KdpLogFileName
Definition: kdio.c:29
static VOID NTAPI KdpLoggerThread(PVOID Context)
Definition: kdio.c:108
Status
Definition: gdiplustypes.h:24
PUCHAR KdComPortInUse
Definition: usage.c:17
return Iosb
Definition: create.c:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KdpBufferSize
Definition: kdio.c:20
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static PCHAR KdpDebugBuffer
Definition: kdio.c:23
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define SYNCHRONIZE
Definition: nt_native.h:61
struct _FileName FileName
Definition: fatprocs.h:893
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define NULL
Definition: types.h:112
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:211
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:49

Referenced by KdpPrintToLogFile().

◆ KdpLoggerThread()

static VOID NTAPI KdpLoggerThread ( PVOID  Context)
static

Definition at line 108 of file kdio.c.

109 {
110  ULONG beg, end, num;
112 
114 
116 
117  while (TRUE)
118  {
120 
121  /* Bug */
122  /* Keep KdpCurrentPosition and KdpFreeBytes values in local
123  * variables to avoid their possible change from Producer part,
124  * KdpPrintToLogFile function
125  */
127  num = KdpFreeBytes;
128 
129  /* Now securely calculate values, based on local variables */
130  beg = (end + num) % KdpBufferSize;
131  num = KdpBufferSize - num;
132 
133  /* Nothing to do? */
134  if (num == 0)
135  continue;
136 
137  if (end > beg)
138  {
140  KdpDebugBuffer + beg, num, NULL, NULL);
141  }
142  else
143  {
145  KdpDebugBuffer + beg, KdpBufferSize - beg, NULL, NULL);
146 
149  }
150 
152  }
153 }
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:21
static HANDLE KdpLogFileHandle
Definition: kdio.c:28
static volatile ULONG KdpFreeBytes
Definition: kdio.c:25
#define TRUE
Definition: types.h:120
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:3070
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:27
#define FALSE
Definition: types.h:117
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:24
#define ASSERT(a)
Definition: mode.c:44
return Iosb
Definition: create.c:4402
#define InterlockedExchangeAddUL(Addend, Value)
Definition: ex.h:1531
GLuint GLuint num
Definition: glext.h:9618
#define KdpBufferSize
Definition: kdio.c:20
static PCHAR KdpDebugBuffer
Definition: kdio.c:23
GLuint GLuint end
Definition: gl.h:1545
#define VOID
Definition: acefi.h:82
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1

Referenced by KdpDebugLogInit().

◆ KdpPrintString()

BOOLEAN NTAPI KdpPrintString ( _In_ PSTRING  Output)

Definition at line 22 of file kdprint.c.

24 {
26  DBGKD_DEBUG_IO DebugIo;
27  USHORT Length;
28 
29  /* Copy the string */
31  Output->Buffer,
32  Output->Length);
33 
34  /* Make sure we don't exceed the KD Packet size */
35  Length = Output->Length;
36  if ((sizeof(DBGKD_DEBUG_IO) + Length) > PACKET_MAX_SIZE)
37  {
38  /* Normalize length */
40  }
41 
42  /* Build the packet header */
45  DebugIo.Processor = KeGetCurrentPrcb()->Number;
47  Header.Length = sizeof(DBGKD_DEBUG_IO);
48  Header.Buffer = (PCHAR)&DebugIo;
49 
50  /* Build the data */
51  Data.Length = Length;
52  Data.Buffer = KdpMessageBuffer;
53 
54  /* Send the packet */
56 
57  /* Check if the user pressed CTRL+C */
59 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI KdpMoveMemory(_In_ PVOID Destination, _In_ PVOID Source, _In_ SIZE_T Length)
Definition: kdapi.c:22
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
#define PACKET_MAX_SIZE
Definition: windbgkd.h:18
ULONG ApiNumber
Definition: windbgkd.h:401
CHAR KdpMessageBuffer[0x1000]
Definition: kddata.c:127
Definition: Header.h:8
#define DbgKdPrintStringApi
Definition: windbgkd.h:122
struct _DBGKD_DEBUG_IO DBGKD_DEBUG_IO
USHORT ProcessorLevel
Definition: windbgkd.h:402
BOOLEAN NTAPI KdpPollBreakInWithPortLock(VOID)
Definition: kdlock.c:35
KD_CONTEXT KdpContext
Definition: kddata.c:65
#define PCHAR
Definition: match.c:90
std::wstring STRING
Definition: fontsub.cpp:33
Definition: arc.h:85
DBGKD_PRINT_STRING PrintString
Definition: windbgkd.h:406
unsigned short USHORT
Definition: pedump.c:61
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
USHORT KeProcessorLevel
Definition: krnlinit.c:20
VOID NTAPI KdSendPacket(IN ULONG PacketType, IN PSTRING MessageHeader, IN PSTRING MessageData, IN OUT PKD_CONTEXT KdContext)
Definition: kddll.c:314
USHORT Processor
Definition: windbgkd.h:403
union _DBGKD_DEBUG_IO::@3495 u

Referenced by KdpDprintf(), KdpPrint(), and KdReceivePacket().

◆ KdpPrintToLogFile()

static VOID NTAPI KdpPrintToLogFile ( PCHAR  String,
ULONG  StringLength 
)
static

Definition at line 157 of file kdio.c.

159 {
160  KIRQL OldIrql;
161  ULONG beg, end, num;
162  BOOLEAN DoReinit = FALSE;
163 
164  if (KdpDebugBuffer == NULL) return;
165 
166  /* Acquire the printing spinlock without waiting at raised IRQL */
168 
169  beg = KdpCurrentPosition;
170  num = KdpFreeBytes;
171  if (StringLength < num)
172  num = StringLength;
173 
174  if (num != 0)
175  {
176  end = (beg + num) % KdpBufferSize;
178  KdpFreeBytes -= num;
179 
180  if (end > beg)
181  {
183  }
184  else
185  {
188  }
189  }
190 
191  /* Release the spinlock */
193  {
194  DoReinit = TRUE;
195  }
197 
198  if (DoReinit)
199  {
201  KdpDebugLogInit(NULL, 3);
202  }
203 
204  /* Signal the logger thread */
207 }
static BOOLEAN KdpLoggingEnabled
Definition: kdio.c:21
static volatile ULONG KdpFreeBytes
Definition: kdio.c:25
#define TRUE
Definition: types.h:120
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:67
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
ULONG ExpInitializationPhase
Definition: init.c:66
static KEVENT KdpLoggerThreadEvent
Definition: kdio.c:27
static KSPIN_LOCK KdpDebugLogSpinLock
Definition: kdio.c:26
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
static volatile ULONG KdpCurrentPosition
Definition: kdio.c:24
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:93
GLuint GLuint num
Definition: glext.h:9618
#define KdpBufferSize
Definition: kdio.c:20
static BOOLEAN KdpLoggingStarting
Definition: kdio.c:22
static PCHAR KdpDebugBuffer
Definition: kdio.c:23
GLuint GLuint end
Definition: gl.h:1545
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:211

Referenced by KdpDebugLogInit().

◆ KdpReleaseLock()

VOID NTAPI KdpReleaseLock ( IN PKSPIN_LOCK  SpinLock,
IN KIRQL  OldIrql 
)

Definition at line 93 of file kdio.c.

95 {
96  /* Release the spinlock */
98  // KeReleaseSpinLockFromDpcLevel(SpinLock);
99 
100  /* Restore the old IRQL */
102 }
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:298

Referenced by KdpPrintToLogFile(), KdpScreenPrint(), KdpSerialDebugPrint(), and KdReceivePacket().

◆ KdpScreenAcquire()

VOID KdpScreenAcquire ( VOID  )

Definition at line 368 of file kdio.c.

369 {
370  if (InbvIsBootDriverInstalled() /* &&
371  !InbvCheckDisplayOwnership() */)
372  {
373  /* Acquire ownership and reset the display */
381  }
382 }
#define TRUE
Definition: types.h:120
#define SCREEN_WIDTH
Definition: pc98video.c:27
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:716
#define BV_COLOR_WHITE
Definition: display.h:30
VOID NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:692
#define SCREEN_HEIGHT
Definition: pc98video.c:28
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:528
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:606
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:630
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:664
#define NULL
Definition: types.h:112
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:622
#define BV_COLOR_BLACK
Definition: display.h:15
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:681

Referenced by KdbpInternalEnter(), and KdpScreenInit().

◆ KdpScreenInit()

VOID NTAPI KdpScreenInit ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Definition at line 500 of file kdio.c.

502 {
503  if (!KdpDebugMode.Screen) return;
504 
505  if (BootPhase == 0)
506  {
507  /* Write out the functions that we support for now */
508  DispatchTable->KdpInitRoutine = KdpScreenInit;
509  DispatchTable->KdpPrintRoutine = KdpScreenPrint;
510 
511  /* Register as a Provider */
512  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
513  }
514  else if (BootPhase == 1)
515  {
516  /* Allocate a buffer for dmesg log buffer. +1 for terminating null,
517  * see kdbp_cli.c:KdbpCmdDmesg()/2
518  */
523 
524  /* Take control of the display */
526 
527  /* Initialize spinlock */
529 
530  HalDisplayString("\r\n Screen debugging enabled\r\n\r\n");
531  }
532 }
PCHAR KdpDmesgBuffer
Definition: kdio.c:41
static KSPIN_LOCK KdpDmesgLogSpinLock
Definition: kdio.c:46
#define InsertTailList(ListHead, Entry)
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
static VOID NTAPI KdpScreenPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:406
VOID NTAPI KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:500
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
volatile ULONG KdbDmesgTotalWritten
Definition: kdio.c:44
VOID KdpScreenAcquire(VOID)
Definition: kdio.c:368
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:43
const ULONG KdpDmesgBufferSize
Definition: kdio.c:40
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:49

◆ KdpScreenPrint()

static VOID NTAPI KdpScreenPrint ( PCHAR  Message,
ULONG  Length 
)
static

Definition at line 406 of file kdio.c.

408 {
409  PCHAR pch = (PCHAR)Message;
410  KIRQL OldIrql;
411  ULONG beg, end, num;
412 
413  while (pch < Message + Length && *pch)
414  {
415  if (*pch == '\b')
416  {
417  /* HalDisplayString does not support '\b'. Workaround it and use '\r' */
418  if (KdpScreenLineLength > 0)
419  {
420  /* Remove last character from buffer */
423 
424  /* Clear row and print line again */
425  HalDisplayString("\r");
427  }
428  }
429  else
430  {
433  }
434 
436  {
437  /* Print buffered characters */
440 
441  /* Clear line buffer */
442  KdpScreenLineBuffer[0] = '\0';
444  }
445 
446  ++pch;
447  }
448 
449  /* Print buffered characters */
451  {
454  }
455 
456  /* Dmesg: store Message in the buffer to show it later */
457  if (KdbpIsInDmesgMode)
458  return;
459 
460  if (KdpDmesgBuffer == NULL)
461  return;
462 
463  /* Acquire the printing spinlock without waiting at raised IRQL */
465 
466  /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize);
467  * set num to min(KdpDmesgFreeBytes, Length).
468  */
471  if (num != 0)
472  {
473  end = (beg + num) % KdpDmesgBufferSize;
474  if (end > beg)
475  {
477  }
478  else
479  {
482  }
484 
485  /* Counting the total bytes written */
487  }
488 
489  /* Release the spinlock */
491 
492  /* Optional step(?): find out a way to notify about buffer exhaustion,
493  * and possibly fall into kbd to use dmesg command: user will read
494  * debug messages before they will be wiped over by next writes.
495  */
496 }
signed char * PCHAR
Definition: retypes.h:7
static CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1]
Definition: kdio.c:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
volatile ULONG KdpDmesgCurrentPosition
Definition: kdio.c:42
PCHAR KdpDmesgBuffer
Definition: kdio.c:41
static ULONG KdpScreenLineLength
Definition: kdio.c:38
static KSPIN_LOCK KdpDmesgLogSpinLock
Definition: kdio.c:46
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:67
#define pch(ap)
Definition: match.c:418
UCHAR KIRQL
Definition: env_spec_w32.h:591
volatile ULONG KdbDmesgTotalWritten
Definition: kdio.c:44
#define PCHAR
Definition: match.c:90
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:93
GLuint GLuint num
Definition: glext.h:9618
#define KdpScreenLineLengthDefault
Definition: kdio.c:36
GLuint GLuint end
Definition: gl.h:1545
CHAR Message[80]
Definition: alive.c:5
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
volatile ULONG KdpDmesgFreeBytes
Definition: kdio.c:43
const ULONG KdpDmesgBufferSize
Definition: kdio.c:40
#define NULL
Definition: types.h:112
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
static ULONG KdpScreenLineBufferPos
Definition: kdio.c:38
volatile BOOLEAN KdbpIsInDmesgMode
Definition: kdio.c:45
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by KdpScreenInit().

◆ KdpScreenRelease()

VOID KdpScreenRelease ( VOID  )

Definition at line 387 of file kdio.c.

388 {
391  {
392  /* Release the display */
393  // InbvSetDisplayOwnership(FALSE);
395  }
396 }
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:638
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:630
#define NULL
Definition: types.h:112
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:553

Referenced by KdbpInternalEnter().

◆ KdpSerialDebugPrint()

VOID NTAPI KdpSerialDebugPrint ( PCHAR  Message,
ULONG  Length 
)

Definition at line 308 of file kdio.c.

310 {
311  PCHAR pch = (PCHAR)Message;
312  KIRQL OldIrql;
313 
314  /* Acquire the printing spinlock without waiting at raised IRQL */
316 
317  /* Output the message */
318  while (pch < Message + Length && *pch != '\0')
319  {
320  if (*pch == '\n')
321  {
323  }
325  pch++;
326  }
327 
328  /* Release the spinlock */
330 }
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:67
#define pch(ap)
Definition: match.c:418
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
#define PCHAR
Definition: match.c:90
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:93
CHAR Message[80]
Definition: alive.c:5
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:32
CPPORT SerialPortInfo
Definition: kdio.c:34

Referenced by KdpSerialInit().

◆ KdpSerialInit()

VOID NTAPI KdpSerialInit ( PKD_DISPATCH_TABLE  DispatchTable,
ULONG  BootPhase 
)

Definition at line 334 of file kdio.c.

336 {
337  if (!KdpDebugMode.Serial) return;
338 
339  if (BootPhase == 0)
340  {
341  /* Write out the functions that we support for now */
342  DispatchTable->KdpInitRoutine = KdpSerialInit;
343  DispatchTable->KdpPrintRoutine = KdpSerialDebugPrint;
344 
345  /* Initialize the Port */
347  {
348  KdpDebugMode.Serial = FALSE;
349  return;
350  }
352 
353  /* Initialize spinlock */
355 
356  /* Register as a Provider */
357  InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
358  }
359  else if (BootPhase == 1)
360  {
361  HalDisplayString("\r\n Serial debugging enabled\r\n\r\n");
362  }
363 }
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:334
#define InsertTailList(ListHead, Entry)
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
BOOLEAN NTAPI KdPortInitializeEx(PCPPORT PortInformation, ULONG ComPortNumber)
#define FALSE
Definition: types.h:117
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
PUCHAR KdComPortInUse
Definition: usage.c:17
VOID NTAPI KdpSerialDebugPrint(PCHAR Message, ULONG Length)
Definition: kdio.c:308
PUCHAR Address
Definition: cportlib.h:29
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:32
CPPORT SerialPortInfo
Definition: kdio.c:34
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
ULONG SerialPortNumber
Definition: kdio.c:33
_In_ PWDFDEVICE_INIT _In_ PWDF_PDO_EVENT_CALLBACKS DispatchTable
Definition: wdfpdo.h:245
LIST_ENTRY KdProviders
Definition: kdio.c:49

◆ KdReceivePacket()

KDSTATUS NTAPI KdReceivePacket ( IN ULONG  PacketType,
OUT PSTRING  MessageHeader,
OUT PSTRING  MessageData,
OUT PULONG  DataLength,
IN OUT PKD_CONTEXT  Context 
)

Definition at line 641 of file kdio.c.

647 {
648 #ifdef KDBG
649  KIRQL OldIrql;
650  STRING StringChar;
651  CHAR Response;
652  USHORT i;
653  ULONG DummyScanCode;
654  CHAR MessageBuffer[100];
655  STRING ResponseString;
656 #endif
657 
658  if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
659  {
660  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
661  RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
663  {
664  ManipulateState->ApiNumber = DbgKdGetContextApi;
665  MessageData->Length = 0;
666  MessageData->Buffer = (PCHAR)&KdbgContext;
667  return KdPacketReceived;
668  }
670  {
671  ManipulateState->ApiNumber = DbgKdSetContextApi;
672  MessageData->Length = sizeof(KdbgContext);
673  MessageData->Buffer = (PCHAR)&KdbgContext;
674  return KdPacketReceived;
675  }
677  {
679  }
680  ManipulateState->ApiNumber = DbgKdContinueApi;
681  ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus;
682 
683  /* Prepare for next time */
686 
687  return KdPacketReceived;
688  }
689 
690  if (PacketType != PACKET_TYPE_KD_DEBUG_IO)
691  return KdPacketTimedOut;
692 
693 #ifdef KDBG
694  ResponseString.Buffer = MessageBuffer;
695  ResponseString.Length = 0;
696  ResponseString.MaximumLength = min(sizeof(MessageBuffer), MessageData->MaximumLength);
697  StringChar.Buffer = &Response;
698  StringChar.Length = StringChar.MaximumLength = sizeof(Response);
699 
700  /* Display the string and print a new line for log neatness */
701  *StringChar.Buffer = '\n';
702  KdpPrintString(&StringChar);
703 
704  /* Print the kdb prompt */
706 
707  // TODO: Use an improved KdbpReadCommand() function for our purposes.
708 
709  /* Acquire the printing spinlock without waiting at raised IRQL */
711 
713  KbdDisableMouse();
714 
715  /* Loop the whole string */
716  for (i = 0; i < ResponseString.MaximumLength; i++)
717  {
718  /* Check if this is serial debugging mode */
720  {
721  /* Get the character from serial */
722  do
723  {
725  } while (Response == -1);
726  }
727  else
728  {
729  /* Get the response from the keyboard */
730  do
731  {
732  Response = KdbpTryGetCharKeyboard(&DummyScanCode, MAXULONG);
733  } while (Response == -1);
734  }
735 
736  /* Check for return */
737  if (Response == '\r')
738  {
739  /*
740  * We might need to discard the next '\n'.
741  * Wait a bit to make sure we receive it.
742  */
744 
745  /* Check the mode */
747  {
748  /* Read and discard the next character, if any */
750  }
751  else
752  {
753  /* Read and discard the next character, if any */
754  KdbpTryGetCharKeyboard(&DummyScanCode, 5);
755  }
756 
757  /*
758  * Null terminate the output string -- documentation states that
759  * DbgPrompt does not null terminate, but it does
760  */
761  *(PCHAR)(ResponseString.Buffer + i) = 0;
762  break;
763  }
764 
765  /* Write it back and print it to the log */
766  *(PCHAR)(ResponseString.Buffer + i) = Response;
768  KdpPrintString(&StringChar);
770  }
771 
772  /* Release the spinlock */
774 
775  /* Print a new line */
776  *StringChar.Buffer = '\n';
777  KdpPrintString(&StringChar);
778 
779  /* Return the length */
780  RtlCopyMemory(MessageData->Buffer, ResponseString.Buffer, i);
781  *DataLength = i;
782 
784  KbdEnableMouse();
785 
786 #endif
787  return KdPacketReceived;
788 }
#define KdPacketReceived
Definition: kddll.h:5
DBGKD_CONTINUE Continue
Definition: windbgkd.h:779
union _DBGKD_MANIPULATE_STATE64::@3506 u
ULONG KdbDebugState
Definition: kdb.c:45
char CHAR
Definition: xmlstorage.h:175
static ULONG KdbgNextApiNumber
Definition: kdio.c:57
KIRQL NTAPI KdpAcquireLock(IN PKSPIN_LOCK SpinLock)
Definition: kdio.c:67
#define DbgKdContinueApi
Definition: windbgkd.h:80
CHAR KdbpTryGetCharSerial(ULONG Retry)
Definition: kdb_serial.c:19
CHAR KdbpTryGetCharKeyboard(PULONG ScanCode, ULONG Retry)
Definition: kdb_keyboard.c:104
UCHAR KIRQL
Definition: env_spec_w32.h:591
STRING KdbPromptString
Definition: kdb_cli.c:165
static NTSTATUS KdbgContinueStatus
Definition: kdio.c:61
VOID KbdEnableMouse(VOID)
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define PCHAR
Definition: match.c:90
#define KdPacketTimedOut
Definition: kddll.h:6
#define DbgKdGetContextApi
Definition: windbgkd.h:76
VOID KbdDisableMouse(VOID)
VOID NTAPI KdpReleaseLock(IN PKSPIN_LOCK SpinLock, IN KIRQL OldIrql)
Definition: kdio.c:93
Definition: ncftp.h:89
std::wstring STRING
Definition: fontsub.cpp:33
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define DbgKdSetContextApi
Definition: windbgkd.h:77
#define MAXULONG
Definition: typedefs.h:251
BOOLEAN NTAPI KdpPrintString(_In_ PSTRING Output)
Definition: kdprint.c:22
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
static KSPIN_LOCK KdpSerialSpinLock
Definition: kdio.c:32
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
NTSTATUS ContinueStatus
Definition: windbgkd.h:559
#define min(a, b)
Definition: monoChain.cc:55
static CONTEXT KdbgContext
Definition: kdio.c:58
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
struct Response Response
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:96

◆ KdSendPacket()

VOID NTAPI KdSendPacket ( IN ULONG  PacketType,
IN PSTRING  MessageHeader,
IN PSTRING  MessageData,
IN OUT PKD_CONTEXT  Context 
)

Definition at line 545 of file kdio.c.

550 {
551  if (PacketType == PACKET_TYPE_KD_DEBUG_IO)
552  {
553  PSTRING Output = MessageData;
554  PLIST_ENTRY CurrentEntry;
555  PKD_DISPATCH_TABLE CurrentTable;
556 
557  if (!KdpDebugMode.Value) return;
558 
559  /* Call the registered handlers */
560  CurrentEntry = KdProviders.Flink;
561  while (CurrentEntry != &KdProviders)
562  {
563  /* Get the current table */
564  CurrentTable = CONTAINING_RECORD(CurrentEntry,
565  KD_DISPATCH_TABLE,
566  KdProvidersList);
567 
568  /* Call it */
569  CurrentTable->KdpPrintRoutine(Output->Buffer, Output->Length);
570 
571  /* Next Table */
572  CurrentEntry = CurrentEntry->Flink;
573  }
574  return;
575  }
576  else if (PacketType == PACKET_TYPE_KD_STATE_CHANGE64)
577  {
578  PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange = (PDBGKD_ANY_WAIT_STATE_CHANGE)MessageHeader->Buffer;
579  if (WaitStateChange->NewState == DbgKdLoadSymbolsStateChange)
580  {
581 #ifdef KDBG
582  PLDR_DATA_TABLE_ENTRY LdrEntry;
583  /* Load symbols. Currently implemented only for KDBG! */
584  if (KdbpSymFindModule((PVOID)(ULONG_PTR)WaitStateChange->u.LoadSymbols.BaseOfDll, -1, &LdrEntry))
585  {
586  KdbSymProcessSymbols(LdrEntry, !WaitStateChange->u.LoadSymbols.UnloadSymbols);
587  }
588 #endif
589  return;
590  }
591  else if (WaitStateChange->NewState == DbgKdExceptionStateChange)
592  {
594  KdbgExceptionRecord = WaitStateChange->u.Exception.ExceptionRecord;
595  KdbgFirstChanceException = WaitStateChange->u.Exception.FirstChance;
596  return;
597  }
598  }
599  else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
600  {
601  PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
602  if (ManipulateState->ApiNumber == DbgKdGetContextApi)
603  {
604  KD_CONTINUE_TYPE Result;
605 
606 #ifdef KDBG
607  /* Check if this is an assertion failure */
609  {
610  /* Bump EIP to the instruction following the int 2C */
612  }
613 
615  KdbgContext.SegCs & 1,
616  &KdbgContext,
618 #else
619  /* We'll manually dump the stack for the user... */
621  Result = kdHandleException;
622 #endif
623  if (Result != kdHandleException)
625  else
628  return;
629  }
630  else if (ManipulateState->ApiNumber == DbgKdSetContextApi)
631  {
633  return;
634  }
635  }
637 }
#define KeRosDumpStackFrames(Frames, Count)
Definition: gdidebug.h:11
struct _DBGKD_ANY_WAIT_STATE_CHANGE * PDBGKD_ANY_WAIT_STATE_CHANGE
static ULONG KdbgNextApiNumber
Definition: kdio.c:57
#define KeGetContextPc(Context)
Definition: ke.h:31
NTSTATUS ExceptionCode
Definition: rtltypes.h:190
#define DbgKdExceptionStateChange
Definition: windbgkd.h:59
#define DbgKdContinueApi
Definition: windbgkd.h:80
if(dx==0 &&dy==0)
Definition: linetemp.h:174
VOID KdbSymProcessSymbols(_Inout_ PLDR_DATA_TABLE_ENTRY LdrEntry, _In_ BOOLEAN Load)
Load symbols from image mapping. If this fails,.
Definition: kdb_symbols.c:298
uint32_t ULONG_PTR
Definition: typedefs.h:65
KDP_DEBUG_MODE KdpDebugMode
Definition: kdio.c:48
DBGKD_LOAD_SYMBOLS64 LoadSymbols
Definition: windbgkd.h:489
ULONG SegCs
Definition: nt_native.h:1477
static NTSTATUS KdbgContinueStatus
Definition: kdio.c:61
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960
#define DbgKdLoadSymbolsStateChange
Definition: windbgkd.h:60
BOOLEAN KdbpSymFindModule(IN PVOID Address OPTIONAL, IN INT Index OPTIONAL, OUT PLDR_DATA_TABLE_ENTRY *pLdrEntry)
Find a module...
Definition: kdb_symbols.c:75
#define DbgKdGetContextApi
Definition: windbgkd.h:76
#define KeSetContextPc(Context, ProgramCounter)
Definition: ke.h:34
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define PACKET_TYPE_KD_STATE_MANIPULATE
Definition: windbgkd.h:43
EXCEPTION_RECORD64 ExceptionRecord
Definition: windbgkd.h:303
#define PACKET_TYPE_KD_STATE_CHANGE64
Definition: windbgkd.h:48
static BOOLEAN KdbgFirstChanceException
Definition: kdio.c:60
Definition: arc.h:85
Definition: btrfs_drv.h:1922
#define DbgKdSetContextApi
Definition: windbgkd.h:77
Definition: typedefs.h:119
static EXCEPTION_RECORD64 KdbgExceptionRecord
Definition: kdio.c:59
#define PACKET_TYPE_KD_DEBUG_IO
Definition: windbgkd.h:44
struct _DBGKD_MANIPULATE_STATE64 * PDBGKD_MANIPULATE_STATE64
static CONTEXT KdbgContext
Definition: kdio.c:58
#define NULL
Definition: types.h:112
DBGKM_EXCEPTION64 Exception
Definition: windbgkd.h:488
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_SUCCESS
Definition: shellext.h:65
union _DBGKD_ANY_WAIT_STATE_CHANGE::@3498 u
LIST_ENTRY KdProviders
Definition: kdio.c:49
KD_CONTINUE_TYPE KdbEnterDebuggerException(IN PEXCEPTION_RECORD64 ExceptionRecord, IN KPROCESSOR_MODE PreviousMode, IN PCONTEXT Context, IN BOOLEAN FirstChance)
KDB Exception filter.
Definition: kdb.c:1258

Variable Documentation

◆ DispatchTable

KD_DISPATCH_TABLE DispatchTable[KdMax]

Definition at line 50 of file kdio.c.

◆ ExpInitializationPhase

ULONG ExpInitializationPhase

Definition at line 66 of file init.c.

Referenced by KdpPrintToLogFile().

◆ InitRoutines

PKDP_INIT_ROUTINE InitRoutines[KdMax]
Initial value:
VOID NTAPI KdpKdbgInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdbg.c:21
VOID NTAPI KdpSerialInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:334
VOID NTAPI KdpScreenInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:500
VOID NTAPI KdpDebugLogInit(PKD_DISPATCH_TABLE DispatchTable, ULONG BootPhase)
Definition: kdio.c:211

Definition at line 52 of file kdio.c.

Referenced by KdDebuggerInitialize0().

◆ KdbDmesgTotalWritten

volatile ULONG KdbDmesgTotalWritten = 0

Definition at line 44 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdbgContext

CONTEXT KdbgContext
static

Definition at line 58 of file kdio.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbgContinueStatus

NTSTATUS KdbgContinueStatus = STATUS_SUCCESS
static

Definition at line 61 of file kdio.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbgExceptionRecord

EXCEPTION_RECORD64 KdbgExceptionRecord
static

Definition at line 59 of file kdio.c.

Referenced by KdSendPacket().

◆ KdbgFirstChanceException

BOOLEAN KdbgFirstChanceException
static

Definition at line 60 of file kdio.c.

Referenced by KdSendPacket().

◆ KdbgNextApiNumber

ULONG KdbgNextApiNumber = DbgKdContinueApi
static

Definition at line 57 of file kdio.c.

Referenced by KdReceivePacket(), and KdSendPacket().

◆ KdbpIsInDmesgMode

volatile BOOLEAN KdbpIsInDmesgMode = FALSE

Definition at line 45 of file kdio.c.

Referenced by KdbpCmdDmesg(), and KdpScreenPrint().

◆ KdbPromptString

◆ KdpCurrentPosition

volatile ULONG KdpCurrentPosition = 0
static

Definition at line 24 of file kdio.c.

Referenced by KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpDebugBuffer

PCHAR KdpDebugBuffer = NULL
static

Definition at line 23 of file kdio.c.

Referenced by KdpDebugLogInit(), KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpDebugLogSpinLock

KSPIN_LOCK KdpDebugLogSpinLock
static

Definition at line 26 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpPrintToLogFile().

◆ KdpDebugMode

◆ KdpDmesgBuffer

PCHAR KdpDmesgBuffer = NULL

Definition at line 41 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdpDmesgBufferSize

const ULONG KdpDmesgBufferSize = 128 * 1024

Definition at line 40 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdpDmesgCurrentPosition

volatile ULONG KdpDmesgCurrentPosition = 0

Definition at line 42 of file kdio.c.

Referenced by KdbpCmdDmesg(), and KdpScreenPrint().

◆ KdpDmesgFreeBytes

volatile ULONG KdpDmesgFreeBytes = 0

Definition at line 43 of file kdio.c.

Referenced by KdbpCmdDmesg(), KdpScreenInit(), and KdpScreenPrint().

◆ KdpDmesgLogSpinLock

KSPIN_LOCK KdpDmesgLogSpinLock
static

Definition at line 46 of file kdio.c.

Referenced by KdpScreenInit(), and KdpScreenPrint().

◆ KdpFreeBytes

volatile ULONG KdpFreeBytes = 0
static

Definition at line 25 of file kdio.c.

Referenced by KdpDebugLogInit(), KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpLogFileHandle

HANDLE KdpLogFileHandle
static

Definition at line 28 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpLoggerThread().

◆ KdpLogFileName

ANSI_STRING KdpLogFileName = RTL_CONSTANT_STRING("\\SystemRoot\\debug.log")

Definition at line 29 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpGetDebugMode().

◆ KdpLoggerThreadEvent

KEVENT KdpLoggerThreadEvent
static

Definition at line 27 of file kdio.c.

Referenced by KdpDebugLogInit(), KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpLoggingEnabled

BOOLEAN KdpLoggingEnabled = FALSE
static

Definition at line 21 of file kdio.c.

Referenced by KdpLoggerThread(), and KdpPrintToLogFile().

◆ KdpLoggingStarting

BOOLEAN KdpLoggingStarting = FALSE
static

Definition at line 22 of file kdio.c.

Referenced by KdpPrintToLogFile().

◆ KdProviders

LIST_ENTRY KdProviders = {&KdProviders, &KdProviders}

◆ KdpScreenLineBuffer

CHAR KdpScreenLineBuffer[KdpScreenLineLengthDefault+1] = ""
static

Definition at line 37 of file kdio.c.

Referenced by KdpScreenPrint().

◆ KdpScreenLineBufferPos

ULONG KdpScreenLineBufferPos = 0
static

Definition at line 38 of file kdio.c.

Referenced by KdpScreenPrint().

◆ KdpScreenLineLength

ULONG KdpScreenLineLength = 0
static

Definition at line 38 of file kdio.c.

Referenced by KdpScreenPrint().

◆ KdpSerialSpinLock

KSPIN_LOCK KdpSerialSpinLock
static

Definition at line 32 of file kdio.c.

Referenced by KdpSerialDebugPrint(), KdpSerialInit(), and KdReceivePacket().

◆ SerialPortInfo

CPPORT SerialPortInfo = {0, DEFAULT_DEBUG_BAUD_RATE, 0}

Definition at line 34 of file kdio.c.

Referenced by KdbpTryGetCharSerial(), KdpGetDebugMode(), KdpSerialDebugPrint(), and KdpSerialInit().

◆ SerialPortNumber

ULONG SerialPortNumber = DEFAULT_DEBUG_PORT

Definition at line 33 of file kdio.c.

Referenced by KdpGetDebugMode(), and KdpSerialInit().