ReactOS 0.4.15-dev-7934-g1dc8d80
kd.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _KDP_DEBUG_MODE
 
struct  _KD_DISPATCH_TABLE
 

Macros

#define DEFAULT_DEBUG_PORT   2 /* COM2 */
 
#define DEFAULT_DEBUG_COM1_IRQ   4 /* COM1 IRQ */
 
#define DEFAULT_DEBUG_COM2_IRQ   3 /* COM2 IRQ */
 
#define DEFAULT_DEBUG_BAUD_RATE   115200 /* 115200 Baud */
 
#define KdScreen   0
 
#define KdSerial   1
 
#define KdFile   2
 
#define KdKdbg   3
 
#define KdMax   4
 

Typedefs

typedef NTSTATUS(NTAPIPKDP_INIT_ROUTINE) (_In_ struct _KD_DISPATCH_TABLE *DispatchTable, _In_ ULONG BootPhase)
 
typedef VOID(NTAPIPKDP_PRINT_ROUTINE) (_In_ PCCH String, _In_ ULONG Length)
 
typedef struct _KDP_DEBUG_MODE KDP_DEBUG_MODE
 
typedef struct _KD_DISPATCH_TABLE KD_DISPATCH_TABLE
 
typedef struct _KD_DISPATCH_TABLEPKD_DISPATCH_TABLE
 

Functions

VOID KdIoPuts (_In_ PCSTR String)
 
VOID __cdecl KdIoPrintf (_In_ PCSTR Format,...)
 
SIZE_T KdIoReadLine (_Out_ PCHAR Buffer, _In_ SIZE_T Size)
 Reads a line of user input from the terminal.
 
KIRQL NTAPI KdbpAcquireLock (_In_ PKSPIN_LOCK SpinLock)
 
VOID NTAPI KdbpReleaseLock (_In_ PKSPIN_LOCK SpinLock, _In_ KIRQL OldIrql)
 
VOID KdpScreenAcquire (VOID)
 
VOID KdpScreenRelease (VOID)
 
NTSTATUS NTAPI KdpScreenInit (_In_ struct _KD_DISPATCH_TABLE *DispatchTable, _In_ ULONG BootPhase)
 
NTSTATUS NTAPI KdpSerialInit (_In_ struct _KD_DISPATCH_TABLE *DispatchTable, _In_ ULONG BootPhase)
 
NTSTATUS NTAPI KdpDebugLogInit (_In_ struct _KD_DISPATCH_TABLE *DispatchTable, _In_ ULONG BootPhase)
 

Variables

KDP_DEBUG_MODE KdpDebugMode
 
ULONG SerialPortNumber
 
CPPORT SerialPortInfo
 
ANSI_STRING KdpLogFileName
 
PKDP_INIT_ROUTINE InitRoutines [KdMax]
 
KD_DISPATCH_TABLE DispatchTable [KdMax]
 
LIST_ENTRY KdProviders
 

Macro Definition Documentation

◆ DEFAULT_DEBUG_BAUD_RATE

#define DEFAULT_DEBUG_BAUD_RATE   115200 /* 115200 Baud */

Definition at line 83 of file kd.h.

◆ DEFAULT_DEBUG_COM1_IRQ

#define DEFAULT_DEBUG_COM1_IRQ   4 /* COM1 IRQ */

Definition at line 81 of file kd.h.

◆ DEFAULT_DEBUG_COM2_IRQ

#define DEFAULT_DEBUG_COM2_IRQ   3 /* COM2 IRQ */

Definition at line 82 of file kd.h.

◆ DEFAULT_DEBUG_PORT

#define DEFAULT_DEBUG_PORT   2 /* COM2 */

Definition at line 80 of file kd.h.

◆ KdFile

#define KdFile   2

Definition at line 88 of file kd.h.

◆ KdKdbg

#define KdKdbg   3

Definition at line 89 of file kd.h.

◆ KdMax

#define KdMax   4

Definition at line 90 of file kd.h.

◆ KdScreen

#define KdScreen   0

Definition at line 86 of file kd.h.

◆ KdSerial

#define KdSerial   1

Definition at line 87 of file kd.h.

Typedef Documentation

◆ KD_DISPATCH_TABLE

◆ KDP_DEBUG_MODE

◆ PKD_DISPATCH_TABLE

◆ PKDP_INIT_ROUTINE

typedef NTSTATUS(NTAPI * PKDP_INIT_ROUTINE) (_In_ struct _KD_DISPATCH_TABLE *DispatchTable, _In_ ULONG BootPhase)

Definition at line 8 of file kd.h.

◆ PKDP_PRINT_ROUTINE

typedef VOID(NTAPI * PKDP_PRINT_ROUTINE) (_In_ PCCH String, _In_ ULONG Length)

Definition at line 14 of file kd.h.

Function Documentation

◆ KdbpAcquireLock()

KIRQL NTAPI KdbpAcquireLock ( _In_ PKSPIN_LOCK  SpinLock)

Definition at line 64 of file kdio.c.

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

Referenced by KdbDebugPrint(), KdpPrintToLogFile(), and KdpSerialPrint().

◆ KdbpReleaseLock()

VOID NTAPI KdbpReleaseLock ( _In_ PKSPIN_LOCK  SpinLock,
_In_ KIRQL  OldIrql 
)

Definition at line 91 of file kdio.c.

94{
95 /* Release the spinlock */
97 // KeReleaseSpinLockFromDpcLevel(SpinLock);
98
99 /* Restore the old IRQL */
101}
VOID FASTCALL KiReleaseSpinLock(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:298

Referenced by KdbDebugPrint(), KdpPrintToLogFile(), and KdpSerialPrint().

◆ KdIoPrintf()

VOID __cdecl KdIoPrintf ( _In_ PCSTR  Format,
  ... 
)

Definition at line 576 of file kdio.c.

579{
580 va_list ap;
582 CHAR Buffer[512];
583
584 /* Format the string */
587 sizeof(Buffer),
588 Format,
589 ap);
590 va_end(ap);
591
592 /* Send it to the display providers */
594}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: bufpool.h:45
static VOID KdIoPrintString(_In_ PCCH String, _In_ ULONG Length)
Definition: kdio.c:547
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint32_t ULONG
Definition: typedefs.h:59
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define _vsnprintf
Definition: xmlstorage.h:202
char CHAR
Definition: xmlstorage.h:175

Referenced by KdIoReadLine(), KdReceivePacket(), and KdSendPacket().

◆ KdIoPuts()

VOID KdIoPuts ( _In_ PCSTR  String)

Definition at line 568 of file kdio.c.

570{
572}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by KdIoReadLine(), and KdReceivePacket().

◆ KdIoReadLine()

SIZE_T KdIoReadLine ( _Out_ PCHAR  Buffer,
_In_ SIZE_T  Size 
)

Reads a line of user input from the terminal.

Parameters
[out]BufferBuffer where to store the input. Trailing newlines are removed.
[in]SizeSize of Buffer.
Returns
Returns the number of characters stored, not counting the NULL terminator.
Note
Accepts only
newlines, \r is ignored.

Definition at line 51 of file kdprompt.c.

54{
55 PCHAR Orig = Buffer;
56 ULONG ScanCode = 0;
57 CHAR Key;
59 LONG CmdHistIndex = -1; // Start at end of history.
60
61 /* Flush the input buffer */
63
64 /* Bail out if the buffer is zero-sized */
65 if (Size == 0)
66 return 0;
67
68 for (;;)
69 {
71
72 /* Check for return or newline */
73 if ((Key == '\r') || (Key == '\n'))
74 {
76 KdIoPuts("\n");
77 return (SIZE_T)(Buffer - Orig);
78 }
79 else if (Key == KEY_BS || Key == KEY_DEL)
80 {
81 /* Erase the last character */
82 if (Buffer > Orig)
83 {
84 Buffer--;
86
87 if (EchoOn)
88 KdIoPrintf("%c %c", KEY_BS, KEY_BS);
89 else
90 KdIoPrintf(" %c", KEY_BS);
91 }
92 }
94 {
95 PCSTR CmdHistory = KdbGetHistoryEntry(&CmdHistIndex,
97 if (CmdHistory)
98 {
99 SIZE_T i;
100
101 /* Erase the whole line */
102 while (Buffer > Orig)
103 {
104 Buffer--;
105 *Buffer = ANSI_NULL;
106
107 if (EchoOn)
108 KdIoPrintf("%c %c", KEY_BS, KEY_BS);
109 else
110 KdIoPrintf(" %c", KEY_BS);
111 }
112
113 /* Copy and display the history entry */
114 i = min(strlen(CmdHistory), Size - 1);
115 memcpy(Orig, CmdHistory, i);
116 Orig[i] = ANSI_NULL;
117 Buffer = Orig + i;
118 KdIoPuts(Orig);
119 }
120 }
121 else
122 {
123 /* Do not accept characters anymore if the buffer is full */
124 if ((SIZE_T)(Buffer - Orig) >= (Size - 1))
125 continue;
126
127 if (EchoOn)
128 KdIoPrintf("%c", Key);
129
130 *Buffer = Key;
131 Buffer++;
132 }
133 }
134}
unsigned char BOOLEAN
UINT ScanCode
Definition: VirtualKey.c:24
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
VOID __cdecl KdIoPrintf(_In_ PCSTR Format,...)
Definition: kdio.c:576
VOID KdIoPuts(_In_ PCSTR String)
Definition: kdio.c:568
PCSTR KdbGetHistoryEntry(_Inout_ PLONG NextIndex, _In_ BOOLEAN Next)
Definition: kdprompt.c:24
VOID KdpFlushTerminalInput(VOID)
Flushes terminal input (either serial or PS/2).
Definition: kdterminal.c:197
ULONG KdbDebugState
Definition: kdterminal.c:32
CHAR KdpReadTermKey(_Out_ PULONG ScanCode)
Reads one character from the terminal. This function returns a scan code even when reading is done fr...
Definition: kdterminal.c:217
@ KD_DEBUG_KDNOECHO
Definition: kdterminal.h:37
#define KEY_SCAN_DOWN
Definition: kdterminal.h:15
#define KEY_BS
Definition: kdterminal.h:10
#define KEY_SCAN_UP
Definition: kdterminal.h:14
#define KEY_DEL
Definition: kdterminal.h:12
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define ANSI_NULL
long LONG
Definition: pedump.c:60
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by KdReceivePacket().

◆ KdpDebugLogInit()

NTSTATUS NTAPI KdpDebugLogInit ( _In_ struct _KD_DISPATCH_TABLE DispatchTable,
_In_ ULONG  BootPhase 
)

◆ KdpScreenAcquire()

VOID KdpScreenAcquire ( VOID  )

Definition at line 431 of file kdio.c.

432{
433 if (InbvIsBootDriverInstalled() /* &&
434 !InbvCheckDisplayOwnership() */)
435 {
436 /* Acquire ownership and reset the display */
444 }
445}
#define NULL
Definition: types.h:112
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:290
VOID NTAPI InbvInstallDisplayStringFilter(_In_ INBV_DISPLAY_STRING_FILTER DisplayFilter)
Definition: inbv.c:387
VOID NTAPI InbvSetTextColor(_In_ ULONG Color)
Definition: inbv.c:460
BOOLEAN NTAPI InbvEnableDisplayString(_In_ BOOLEAN Enable)
Definition: inbv.c:370
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:431
VOID NTAPI InbvSetScrollRegion(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom)
Definition: inbv.c:448
VOID NTAPI InbvSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ ULONG Color)
Definition: inbv.c:485
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:396
#define SCREEN_WIDTH
Definition: pc98video.c:27
#define SCREEN_HEIGHT
Definition: pc98video.c:28
#define BV_COLOR_WHITE
Definition: display.h:30
#define BV_COLOR_BLACK
Definition: display.h:15

Referenced by KdbpInternalEnter(), and KdpScreenInit().

◆ KdpScreenInit()

NTSTATUS NTAPI KdpScreenInit ( _In_ struct _KD_DISPATCH_TABLE DispatchTable,
_In_ ULONG  BootPhase 
)

◆ KdpScreenRelease()

VOID KdpScreenRelease ( VOID  )

Definition at line 450 of file kdio.c.

451{
454 {
455 /* Release the display */
456 // InbvSetDisplayOwnership(FALSE);
458 }
459}
VOID NTAPI InbvNotifyDisplayOwnershipLost(_In_ INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:404
BOOLEAN NTAPI InbvCheckDisplayOwnership(VOID)
Definition: inbv.c:316

Referenced by KdbpInternalEnter().

◆ KdpSerialInit()

NTSTATUS NTAPI KdpSerialInit ( _In_ struct _KD_DISPATCH_TABLE DispatchTable,
_In_ ULONG  BootPhase 
)

Variable Documentation

◆ DispatchTable

Definition at line 17 of file global.c.

◆ InitRoutines

PKDP_INIT_ROUTINE InitRoutines[KdMax]
extern

Definition at line 50 of file kdio.c.

Referenced by KdDebuggerInitialize0().

◆ KdpDebugMode

◆ KdpLogFileName

ANSI_STRING KdpLogFileName
extern

Definition at line 36 of file kdio.c.

Referenced by KdpDebugLogInit(), and KdpGetDebugMode().

◆ KdProviders

◆ SerialPortInfo

CPPORT SerialPortInfo
extern

◆ SerialPortNumber

ULONG SerialPortNumber
extern

Definition at line 39 of file kdio.c.

Referenced by KdpGetDebugMode(), and KdpSerialInit().