From 39f866e05f703d64f621d77b135b7958d0ccf110 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Tue, 22 Mar 2011 15:27:49 +0800 Subject: clarified comments regarding usb and gdb message formats --- Debugger/debug_comm.S | 25 +++++++++++++++---------- Debugger/debug_stub.h | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Debugger/debug_comm.S b/Debugger/debug_comm.S index a43cc5f..75f835e 100644 --- a/Debugger/debug_comm.S +++ b/Debugger/debug_comm.S @@ -338,14 +338,16 @@ _exit_conv_ascii2byte: * Byte 3-N: Message data | GDB Command * * The GDB Command (of size M) has the following format: - * Offset 0: '$' - * Offset 1: GDB Command char - * Offset 2 - (M-4): Command packet info + * Offset 0: '+'/'-' Command Received Status (Optional) + * Offset 1/0: '$' + * Offset 2/1: GDB Command char + * Offset 3 - (M-4): Command packet info * Offset M-3: '#' * Offset M-2: MSB of Checksum * Offset M-1: LSB of Checksum * - * The maximum size of a GDB Command packet is MSGBUF_SIZE - 4 ('$', '#', 2 byte checksum) + * To be safe, we assume that the Command Received Status is always sent by the GDB server. Therefore, + * The maximum size of a GDB Command packet is MSGBUF_SIZE - 5 ('+'/'-', '$', '#', 2 byte checksum) * * GDB Response * ============ @@ -354,15 +356,18 @@ _exit_conv_ascii2byte: * Byte 2: Telegram Size (Len of USB Buffer - 3, max is MSG_SEGMENTSIZE) | * Byte 3-N: Message data | GDB Response * + * The GDB Retransmission Request has the following format: + * Offset 0: '-' Command Received Status + * * The GDB Response (of size M) has the following format: - * Offset 0: '+' or '-' Command Received Status + * Offset 0: '+' Command Received Status * Offset 1: '$' * Offset 2 - (M-4): Response packet info * Offset M-3: '#' * Offset M-2: MSB of Checksum * Offset M-1: LSB of Checksum * - * The maximum size of a GDB Response packet is MSGBUF_SIZE - 5 ('-'/'+', '$', '#', 2 byte checksum) + * The maximum size of a GDB Response packet is MSGBUF_SIZE - 5 ('+', '$', '#', 2 byte checksum) * * Note: The Telegram Size is the actual size of the Message Data portion * (i.e., excludes the three header bytes, includes the GDB Command/Response Packet checksum bytes @@ -723,7 +728,7 @@ _exit_copy_msg_to_usbbuf: * On exit: * r0: status (0: success, -1: error) * Note: GDB Message to be sent must be ASCIIZ terminated, does not include '#' and checksum - * Response packets start with '+'/'-' followed by '$' (2 bytes prefix) + * Response packets start with '+' followed by '$' (2 bytes prefix) */ dbg__putDebugMsg: stmfd sp!, {r4,r5,lr} @@ -731,8 +736,8 @@ dbg__putDebugMsg: ldr r5, =debug_msgTxBufPtr /* R5: data structure base pointer */ ldr r4, [r5] /* Tx buffer Start Address */ str r4, [r5, #TXAPPENDPTR_OFFSET] /* Reset Tx buffer Append Pointer */ - add r0, r4, #2 /* skip '+'/'-' and '$' */ - bl _msgbuf_checksum /* R2: length (excl '+'/'-' and '$'), R1: calculated checksum, R0: pointer to checksum in tx buffer */ + add r0, r4, #2 /* skip '+' and '$' */ + bl _msgbuf_checksum /* R2: length (excl '+' and '$'), R1: calculated checksum, R0: pointer to checksum in tx buffer */ #ifdef CHECK_TXLEN add r2, r2, #2 /* r2: returned length from _msgbuf_checksum, added with prefix length */ @@ -744,7 +749,7 @@ dbg__putDebugMsg: mov r3, #MSGBUF_CHKSUMCHAR strb r3, [r0, #-1] /* Insert '#' */ bl byte2ascii /* On return, R0 points to location after checksum bytes, R1 is original pointer to checksum */ - sub r4, r0, r4 /* R4 = Calculated total message length (incl '+'/'-' and '$', '#' and checksum bytes */ + sub r4, r0, r4 /* R4 = Calculated total message length (incl '+' and '$', '#' and checksum bytes */ cmp r4, #MSG_SEGMENTSIZE /* If total message length > MSG_SEGMENTSIZE */ mov r1, #0 /* Initialize Segment Number = 0 (last segment) first */ mov r0, #0 /* Initial cummulative message length */ diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h index 67f86c4..e39fc8e 100644 --- a/Debugger/debug_stub.h +++ b/Debugger/debug_stub.h @@ -50,8 +50,8 @@ #define MSG_SEGMENTSIZE (USB_BUFSIZE - USB_GDBMSG_START) /* 61 bytes per segment */ #define MSGBUF_SIZE (MSG_SEGMENTSIZE*MSG_NUMSEGMENTS) /* Debug Message Buffer Size, 61 x 3 = 183 chars = ~80 bytes of actual data */ #define MSGBUF_CHKSUMOFFSET 3 /* to be subtracted from message length */ -#define MSGBUF_IN_OVERHEADLEN 5 /* For calculating max message data length (include ASCIIZ char) */ -#define MSGBUF_OUT_OVERHEADLEN 6 /* For calculating max message data length (include ASCIIZ char) */ +#define MSGBUF_IN_OVERHEADLEN 5 /* For calculating max message data length (exclude ASCIIZ char) */ +#define MSGBUF_OUT_OVERHEADLEN 5 /* For calculating max message data length (exclude ASCIIZ char) */ #define MSGBUF_CTRLC 0x03 /* For Out of Band Signaling: not implemented yet */ #define MSGBUF_STARTCHAR '$' -- cgit v1.2.3