ReactOS 0.4.16-dev-2528-g7139e57
kddll.h File Reference
#include <ntifs.h>
#include <windbgkd.h>
Include dependency graph for kddll.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NOEXTAPI
 
#define KDDBGPRINT(...)
 

Enumerations

enum  KDP_STATUS {
  KDP_PACKET_RECEIVED = 0 , KDP_PACKET_TIMEOUT = 1 , KDP_PACKET_RESEND = 2 , KDP_PACKET_RECEIVED = 0 ,
  KDP_PACKET_TIMEOUT = 1 , KDP_PACKET_RESEND = 2
}
 

Functions

VOID NTAPI KdpSendBuffer (IN PVOID Buffer, IN ULONG Size)
 
KDP_STATUS NTAPI KdpReceiveBuffer (OUT PVOID Buffer, IN ULONG Size)
 
KDP_STATUS NTAPI KdpReceivePacketLeader (OUT PULONG PacketLeader)
 
VOID NTAPI KdpSendByte (IN UCHAR Byte)
 
KDP_STATUS NTAPI KdpPollByte (OUT PUCHAR OutByte)
 
KDP_STATUS NTAPI KdpReceiveByte (OUT PUCHAR OutByte)
 
KDP_STATUS NTAPI KdpPollBreakIn (VOID)
 

Macro Definition Documentation

◆ KDDBGPRINT

#define KDDBGPRINT (   ...)

Definition at line 19 of file kddll.h.

◆ NOEXTAPI

#define NOEXTAPI

Definition at line 12 of file kddll.h.

Enumeration Type Documentation

◆ KDP_STATUS

Enumerator
KDP_PACKET_RECEIVED 
KDP_PACKET_TIMEOUT 
KDP_PACKET_RESEND 
KDP_PACKET_RECEIVED 
KDP_PACKET_TIMEOUT 
KDP_PACKET_RESEND 

Definition at line 25 of file kddll.h.

26{
KDP_STATUS
Definition: kddll.h:26
@ KDP_PACKET_TIMEOUT
Definition: kddll.h:28
@ KDP_PACKET_RESEND
Definition: kddll.h:29
@ KDP_PACKET_RECEIVED
Definition: kddll.h:27

Function Documentation

◆ KdpPollBreakIn()

KDP_STATUS NTAPI KdpPollBreakIn ( VOID  )

Definition at line 296 of file kdcom.c.

297{
298 KDP_STATUS KdStatus;
299 UCHAR Byte;
300
301 KdStatus = KdpPollByte(&Byte);
302 if ((KdStatus == KDP_PACKET_RECEIVED) && (Byte == BREAKIN_PACKET_BYTE))
303 {
304 return KDP_PACKET_RECEIVED;
305 }
306 return KDP_PACKET_TIMEOUT;
307}
unsigned char Byte
Definition: zlib.h:37
KDP_STATUS NTAPI KdpPollByte(OUT PUCHAR OutByte)
Definition: kdcom.c:252
#define BREAKIN_PACKET_BYTE
Definition: windbgkd.h:31
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ KdpPollByte()

KDP_STATUS NTAPI KdpPollByte ( OUT PUCHAR  OutByte)

Definition at line 252 of file kdcom.c.

253{
255
256 /* Poll the byte */
257 Status = CpGetByte(&KdComPort, OutByte, FALSE, FALSE);
258 switch (Status)
259 {
260 case CP_GET_SUCCESS:
261 return KDP_PACKET_RECEIVED;
262
263 case CP_GET_NODATA:
264 return KDP_PACKET_TIMEOUT;
265
266 case CP_GET_ERROR:
267 default:
268 return KDP_PACKET_RESEND;
269 }
270}
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 CP_GET_NODATA
Definition: cportlib.h:18
#define CP_GET_ERROR
Definition: cportlib.h:19
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:25
CPPORT KdComPort
Definition: kdcom.c:20
unsigned short USHORT
Definition: pedump.c:61

◆ KdpReceiveBuffer()

KDP_STATUS NTAPI KdpReceiveBuffer ( OUT PVOID  Buffer,
IN ULONG  Size 
)

Definition at line 43 of file kdserial.c.

46{
47 PUCHAR ByteBuffer = Buffer;
48 UCHAR Byte;
50
51 while (Size-- > 0)
52 {
53 /* Try to get a byte from the port */
56 return Status;
57
58 *ByteBuffer++ = Byte;
59 }
60
62}
Definition: bufpool.h:45
KDP_STATUS NTAPI KdpReceiveByte(OUT PUCHAR OutByte)
Definition: kdcom.c:274
unsigned char * PUCHAR
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

Referenced by KdReceivePacket().

◆ KdpReceiveByte()

KDP_STATUS NTAPI KdpReceiveByte ( OUT PUCHAR  OutByte)

Definition at line 274 of file kdcom.c.

275{
277
278 /* Get the byte */
279 Status = CpGetByte(&KdComPort, OutByte, TRUE, FALSE);
280 switch (Status)
281 {
282 case CP_GET_SUCCESS:
283 return KDP_PACKET_RECEIVED;
284
285 case CP_GET_NODATA:
286 return KDP_PACKET_TIMEOUT;
287
288 case CP_GET_ERROR:
289 default:
290 return KDP_PACKET_RESEND;
291 }
292}
#define TRUE
Definition: types.h:120

Referenced by finish_gdb_packet(), gdb_receive_packet(), KdpReceiveBuffer(), and KdpReceivePacketLeader().

◆ KdpReceivePacketLeader()

KDP_STATUS NTAPI KdpReceivePacketLeader ( OUT PULONG  PacketLeader)

Definition at line 75 of file kdserial.c.

77{
78 UCHAR Index = 0, Byte, Buffer[4];
79 KDP_STATUS KdStatus;
80
81 /* Set first character to 0 */
82 Buffer[0] = 0;
83
84 do
85 {
86 /* Receive a single byte */
87 KdStatus = KdpReceiveByte(&Byte);
88
89 /* Check for timeout */
90 if (KdStatus == KDP_PACKET_TIMEOUT)
91 {
92 /* Check if we already got a breakin byte */
94 {
95 return KDP_PACKET_RESEND;
96 }
97
98 /* Report timeout */
99 return KDP_PACKET_TIMEOUT;
100 }
101
102 /* Check if we received a byte */
103 if (KdStatus == KDP_PACKET_RECEIVED)
104 {
105 /* Check if this is a valid packet leader byte */
106 if (Byte == PACKET_LEADER_BYTE ||
108 {
109 /* Check if we match the first byte */
110 if (Byte != Buffer[0])
111 {
112 /* No, this is the new byte 0! */
113 Index = 0;
114 }
115
116 /* Store the byte in the buffer */
117 Buffer[Index] = Byte;
118
119 /* Continue with next byte */
120 Index++;
121 continue;
122 }
123
124 /* Check for breakin byte */
126 {
127 KDDBGPRINT("BREAKIN_PACKET_BYTE\n");
128 Index = 0;
129 Buffer[0] = Byte;
130 continue;
131 }
132 }
133
134 /* Restart */
135 Index = 0;
136 Buffer[0] = 0;
137 }
138 while (Index < 4);
139
140 /* Enable the debugger */
142 SharedUserData->KdDebuggerEnabled |= 0x00000002;
143
144 /* Return the received packet leader */
145 *PacketLeader = *(PULONG)Buffer;
146
147 return KDP_PACKET_RECEIVED;
148}
#define KDDBGPRINT(...)
Definition: kddll.h:19
#define SharedUserData
uint32_t * PULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
#define CONTROL_PACKET_LEADER_BYTE
Definition: windbgkd.h:35
#define PACKET_LEADER_BYTE
Definition: windbgkd.h:33
#define KD_DEBUGGER_NOT_PRESENT
Definition: kdfuncs.h:133

Referenced by KdReceivePacket().

◆ KdpSendBuffer()

VOID NTAPI KdpSendBuffer ( IN PVOID  Buffer,
IN ULONG  Size 
)

Definition at line 21 of file kdserial.c.

24{
25 PUCHAR ByteBuffer = Buffer;
26
27 while (Size-- > 0)
28 {
29 KdpSendByte(*ByteBuffer++);
30 }
31}
VOID NTAPI KdpSendByte(IN UCHAR Byte)
Definition: kdcom.c:244

Referenced by KdpSendControlPacket(), and KdSendPacket().

◆ KdpSendByte()

VOID NTAPI KdpSendByte ( IN UCHAR  Byte)

Definition at line 244 of file kdcom.c.

245{
246 /* Send the byte */
248}
VOID NTAPI CpPutByte(_Inout_ PCPPORT Port, _In_ UCHAR Byte)
Definition: cport.c:93

Referenced by finish_gdb_packet(), gdb_receive_packet(), KdpPollBreakIn(), KdpSendBuffer(), KdSendPacket(), send_gdb_partial_binary(), send_gdb_partial_packet(), and start_gdb_packet().