ReactOS 0.4.15-dev-7942-gd23573b
kdserial.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for kdserial.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define DEFAULT_BAUD_RATE   19200
 
#define MAX_COM_PORTS   (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1)
 

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

◆ DEFAULT_BAUD_RATE

#define DEFAULT_BAUD_RATE   19200

Definition at line 19 of file kdserial.c.

◆ MAX_COM_PORTS

#define MAX_COM_PORTS   (sizeof(BaseArray) / sizeof(BaseArray[0]) - 1)

Definition at line 38 of file kdserial.c.

◆ 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 137 of file kdserial.c.

140{
141 return (CpGetByte(PortInformation, ByteReceived, FALSE, FALSE) == CP_GET_SUCCESS);
142}
#define CP_GET_SUCCESS
Definition: cportlib.h:18
USHORT NTAPI CpGetByte(IN PCPPORT Port, OUT PUCHAR Byte, IN BOOLEAN Wait, IN BOOLEAN Poll)
Definition: cport.c:253
#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 51 of file kdserial.c.

54{
56
57#if 0 // Deactivated because never used in fact (was in KdPortInitialize but we use KdPortInitializeEx)
58 /*
59 * Find the port if needed
60 */
61
62 if (!PortInitialized)
63 {
65
66 if (ComPortNumber == 0)
67 {
68 /*
69 * Start enumerating COM ports from the last one to the first one,
70 * and break when we find a valid port.
71 * If we reach the first element of the list, the invalid COM port,
72 * then it means that no valid port was found.
73 */
74 for (ComPortNumber = MAX_COM_PORTS; ComPortNumber > 0; ComPortNumber--)
75 {
76 if (CpDoesPortExist(UlongToPtr(BaseArray[ComPortNumber])))
77 {
78 PortInformation->Address = DefaultPort.Address = BaseArray[ComPortNumber];
79 break;
80 }
81 }
82 if (ComPortNumber == 0)
83 {
84 HalDisplayString("\r\nKernel Debugger: No COM port found!\r\n\r\n");
85 return FALSE;
86 }
87 }
88
89 PortInitialized = TRUE;
90 }
91#endif
92
93 /*
94 * Initialize the port
95 */
97 (ComPortNumber == 0 ? PortInformation->Address
98 : UlongToPtr(BaseArray[ComPortNumber])),
99 (PortInformation->BaudRate == 0 ? DEFAULT_BAUD_RATE
100 : PortInformation->BaudRate));
101 if (!NT_SUCCESS(Status))
102 {
103 HalDisplayString("\r\nKernel Debugger: Serial port not found!\r\n\r\n");
104 return FALSE;
105 }
106 else
107 {
108#ifndef NDEBUG
109 int Length;
110 CHAR Buffer[82];
111
112 /* Print message to blue screen */
113 Length = snprintf(Buffer, sizeof(Buffer),
114 "\r\nKernel Debugger: Serial port found: COM%ld (Port 0x%p) BaudRate %ld\r\n\r\n",
115 ComPortNumber,
116 PortInformation->Address,
117 PortInformation->BaudRate);
118 if (Length == -1)
119 {
120 /* Terminate it if we went over-board */
121 Buffer[sizeof(Buffer) - 1] = ANSI_NULL;
122 }
123
125#endif /* NDEBUG */
126
127#if 0
128 /* Set global info */
130#endif
131 return TRUE;
132 }
133}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
NTSTATUS NTAPI CpInitialize(IN PCPPORT Port, IN PUCHAR Address, IN ULONG BaudRate)
Definition: cport.c:85
BOOLEAN NTAPI CpDoesPortExist(IN PUCHAR Address)
Definition: cport.c:224
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define UlongToPtr(u)
Definition: config.h:106
Status
Definition: gdiplustypes.h:25
PUCHAR KdComPortInUse
Definition: usage.c:17
static const ULONG BaseArray[]
Definition: hwide.c:41
NTHALAPI VOID NTAPI HalDisplayString(PUCHAR String)
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
CPPORT DefaultPort
Definition: kdserial.c:18
#define DEFAULT_BAUD_RATE
Definition: kdserial.c:19
#define MAX_COM_PORTS
Definition: kdserial.c:38
PUCHAR Address
Definition: cportlib.h:29
ULONG BaudRate
Definition: cportlib.h:30
#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 146 of file kdserial.c.

149{
150 CpPutByte(PortInformation, ByteToSend);
151}
VOID NTAPI CpPutByte(IN PCPPORT Port, IN UCHAR Byte)
Definition: cport.c:303