2 * COPYRIGHT: GPL, see COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/base/kddll/gdb_receive.c
5 * PURPOSE: Base functions for the kernel debugger.
10 /* GLOBALS ********************************************************************/
11 CHAR gdb_input
[0x1000];
13 /* GLOBAL FUNCTIONS ***********************************************************/
17 if ((ch
>= '0') && (ch
<= '9'))
20 if ((ch
>= 'a') && (ch
<= 'f'))
21 return (ch
- 'a' + 10);
23 if ((ch
>= 'A') && (ch
<= 'F'))
24 return (ch
- 'A' + 10);
31 gdb_receive_packet(_Inout_ PKD_CONTEXT KdContext
)
33 char* ByteBuffer
= gdb_input
;
36 CHAR CheckSum
= 0, ReceivedCheckSum
;
40 Status
= KdpReceiveByte(&Byte
);
41 if (Status
!= KdPacketReceived
)
45 KdContext
->KdpControlCPending
= TRUE
;
46 return KdPacketNeedsResend
;
48 } while (Byte
!= '$');
52 /* Try to get a byte from the port */
53 Status
= KdpReceiveByte(&Byte
);
54 if (Status
!= KdPacketReceived
)
64 CheckSum
+= (CHAR
)Byte
;
67 /* Get Check sum (two bytes) */
68 Status
= KdpReceiveByte(&Byte
);
69 if (Status
!= KdPacketReceived
)
71 ReceivedCheckSum
= hex_value(Byte
) << 4;;
73 Status
= KdpReceiveByte(&Byte
);
74 if (Status
!= KdPacketReceived
)
76 ReceivedCheckSum
+= hex_value(Byte
);
79 if (ReceivedCheckSum
!= CheckSum
)
81 /* Do not acknowledge to GDB */
83 return KdPacketNeedsResend
;
89 return KdPacketReceived
;