ReactOS 0.4.16-dev-2498-g8632030
kdserial.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <cportlib/uartinfo.h>
Include dependency graph for kdserial.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI KdPortInitializeEx (IN PCPPORT PortInformation, IN ULONG ComPortNumber)
 
BOOLEAN NTAPI KdPortGetByteEx (IN PCPPORT PortInformation, OUT PUCHAR ByteReceived)
 
VOID NTAPI KdPortPutByteEx (IN PCPPORT PortInformation, IN UCHAR ByteToSend)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file kdserial.c.

Function Documentation

◆ KdPortGetByteEx()

BOOLEAN NTAPI KdPortGetByteEx ( IN PCPPORT  PortInformation,
OUT PUCHAR  ByteReceived 
)

Definition at line 115 of file kdserial.c.

118{
119 return (CpGetByte(PortInformation, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS);
120}
USHORT NTAPI CpGetByte(_Inout_ PCPPORT Port, _Out_ PUCHAR Byte, _In_ BOOLEAN Wait, _In_ BOOLEAN Poll)
Definition: cport.c:82
#define CP_GET_SUCCESS
Definition: cportlib.h:17
#define FALSE
Definition: types.h:117
IN CINT OUT PVOID PortInformation
Definition: dumpinfo.c:40

◆ KdPortInitializeEx()

BOOLEAN NTAPI KdPortInitializeEx ( IN PCPPORT  PortInformation,
IN ULONG  ComPortNumber 
)

Definition at line 30 of file kdserial.c.

33{
35
36#if 0 // Deactivated because never used in fact (was in KdPortInitialize but we use KdPortInitializeEx)
37 /*
38 * Find the port if needed
39 */
40
41 if (!PortInitialized)
42 {
44
45 if (ComPortNumber == 0)
46 {
47 /*
48 * Enumerate COM ports from the last to the first one, and stop
49 * when we find a valid port. If we reach the first list element
50 * (the undefined COM port), no valid port was found.
51 */
52 for (ComPortNumber = MAX_COM_PORTS; ComPortNumber > 0; ComPortNumber--)
53 {
54 if (CpDoesPortExist(UlongToPtr(BaseArray[ComPortNumber])))
55 {
56 PortInformation->Address = DefaultPort.Address = BaseArray[ComPortNumber];
57 break;
58 }
59 }
60 if (ComPortNumber == 0)
61 {
62 HalDisplayString("\r\nKernel Debugger: No serial port found\r\n\r\n");
63 return FALSE;
64 }
65 }
66
67 PortInitialized = TRUE;
68 }
69#endif
70
71 /*
72 * Initialize the port
73 */
75 (ComPortNumber == 0 ? PortInformation->Address
76 : UlongToPtr(BaseArray[ComPortNumber])),
78 : PortInformation->BaudRate));
79 if (!NT_SUCCESS(Status))
80 {
81 HalDisplayString("\r\nKernel Debugger: Serial port not available\r\n\r\n");
82 return FALSE;
83 }
84 else
85 {
86#ifndef NDEBUG
87 int Length;
88 CHAR Buffer[82];
89
90 /* Print message to blue screen */
91 Length = snprintf(Buffer, sizeof(Buffer),
92 "\r\nKernel Debugger: Using COM%lu (Port 0x%p) BaudRate %lu\r\n\r\n",
93 ComPortNumber,
94 PortInformation->Address,
95 PortInformation->BaudRate);
96 if (Length == -1)
97 {
98 /* Terminate it if we went over-board */
99 Buffer[sizeof(Buffer) - 1] = ANSI_NULL;
100 }
101
103#endif /* NDEBUG */
104
105#if 0
106 /* Set global info */
108#endif
109 return TRUE;
110 }
111}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
NTSTATUS NTAPI CpInitialize(_Inout_ PCPPORT Port, _In_ PUCHAR Address, _In_ ULONG BaudRate)
Definition: cport.c:59
BOOLEAN NTAPI CpDoesPortExist(_In_ PUCHAR Address)
Definition: cport.c:33
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define UlongToPtr(u)
Definition: config.h:106
Status
Definition: gdiplustypes.h:25
PUCHAR KdComPortInUse
Definition: usage.c:17
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
#define MAX_COM_PORTS
Definition: machpc.c:29
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
CPPORT DefaultPort
Definition: kdserial.c:18
PUCHAR Address
Definition: cportlib.h:28
ULONG BaudRate
Definition: cportlib.h:29
#define DEFAULT_DEBUG_BAUD_RATE
Definition: uartinfo.h:17
#define snprintf
Definition: wintirpc.h:48
char CHAR
Definition: xmlstorage.h:175

◆ KdPortPutByteEx()

VOID NTAPI KdPortPutByteEx ( IN PCPPORT  PortInformation,
IN UCHAR  ByteToSend 
)

Definition at line 124 of file kdserial.c.

127{
128 CpPutByte(PortInformation, ByteToSend);
129}
VOID NTAPI CpPutByte(_Inout_ PCPPORT Port, _In_ UCHAR Byte)
Definition: cport.c:93