Line 126... |
Line 126... |
with two hex digits per byte and the 'g' reply, which must hold all the
|
with two hex digits per byte and the 'g' reply, which must hold all the
|
registers, and (in our implementation) an end-of-string (0)
|
registers, and (in our implementation) an end-of-string (0)
|
character. Adding the EOS allows us to print out the packet as a
|
character. Adding the EOS allows us to print out the packet as a
|
string. So at least NUMREGBYTES*2 + 1 (for the 'G' or the EOS) are needed
|
string. So at least NUMREGBYTES*2 + 1 (for the 'G' or the EOS) are needed
|
for register packets */
|
for register packets */
|
#define GDB_BUF_MAX ((NUM_REGS) * 8 + 1)
|
//#define GDB_BUF_MAX ((NUM_REGS) * 8 + 1)
|
|
#define GDB_BUF_MAX 4096
|
|
#define GDB_BUF_MAX_TIMES_TWO (GDB_BUF_MAX*2)
|
|
|
/*! Size of the matchpoint hash table. Largest prime < 2^10 */
|
/*! Size of the matchpoint hash table. Largest prime < 2^10 */
|
#define MP_HASH_SIZE 1021
|
#define MP_HASH_SIZE 1021
|
|
|
/* Definition of special-purpose registers (SPRs). */
|
/* Definition of special-purpose registers (SPRs). */
|
Line 249... |
Line 251... |
|
|
/*! Data structure for RSP buffers. Can't be null terminated, since it may
|
/*! Data structure for RSP buffers. Can't be null terminated, since it may
|
include zero bytes */
|
include zero bytes */
|
struct rsp_buf
|
struct rsp_buf
|
{
|
{
|
char data[GDB_BUF_MAX];
|
char data[GDB_BUF_MAX_TIMES_TWO];
|
int len;
|
int len;
|
};
|
};
|
|
|
/*! Enumeration of different types of matchpoint. These have explicit values
|
/*! Enumeration of different types of matchpoint. These have explicit values
|
matching the second digit of 'z' and 'Z' packets. */
|
matching the second digit of 'z' and 'Z' packets. */
|
Line 2193... |
Line 2195... |
put_str_packet ("E01");
|
put_str_packet ("E01");
|
return;
|
return;
|
}
|
}
|
|
|
/* Make sure we won't overflow the buffer (2 chars per byte) */
|
/* Make sure we won't overflow the buffer (2 chars per byte) */
|
if ((len * 2) >= GDB_BUF_MAX)
|
if ((len * 2) >= GDB_BUF_MAX_TIMES_TWO)
|
{
|
{
|
fprintf (stderr, "Warning: Memory read %s too large for RSP packet: "
|
fprintf (stderr, "Warning: Memory read %s too large for RSP packet: "
|
"truncated\n", p_buf->data);
|
"truncated\n", p_buf->data);
|
len = (GDB_BUF_MAX - 1) / 2;
|
len = (GDB_BUF_MAX - 1) / 2;
|
}
|
}
|
Line 3522... |
Line 3524... |
#ifdef OR32_KERNEL_DBG_COMPAT
|
#ifdef OR32_KERNEL_DBG_COMPAT
|
if (IS_VM_ADDR(adr))
|
if (IS_VM_ADDR(adr))
|
adr = adr & ~OR32_LINUX_VM_MASK;
|
adr = adr & ~OR32_LINUX_VM_MASK;
|
#endif
|
#endif
|
|
|
|
|
switch (gdb_chain) { /* remap registers, to be compatible with jp1 */
|
switch (gdb_chain) { /* remap registers, to be compatible with jp1 */
|
case SC_RISC_DEBUG: if (adr == JTAG_RISCOP) adr = 0x00;
|
case SC_RISC_DEBUG: return dbg_cpu0_write(adr, &data, 4) ? ERR_CRC : ERR_NONE;
|
return dbg_cpu0_write(adr, data) ? ERR_CRC : ERR_NONE;
|
|
case SC_REGISTER: return dbg_cpu0_write_ctrl(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_REGISTER: return dbg_cpu0_write_ctrl(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_WISHBONE: return dbg_wb_write32(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_WISHBONE: return dbg_wb_write32(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_TRACE: return 0;
|
case SC_TRACE: return 0;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
}
|
}
|
Line 3540... |
Line 3540... |
if (IS_VM_ADDR(adr))
|
if (IS_VM_ADDR(adr))
|
adr = adr & ~OR32_LINUX_VM_MASK;
|
adr = adr & ~OR32_LINUX_VM_MASK;
|
#endif
|
#endif
|
|
|
switch (gdb_chain) {
|
switch (gdb_chain) {
|
case SC_RISC_DEBUG: return dbg_cpu0_read(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_RISC_DEBUG: return dbg_cpu0_read(adr, data, 4) ? ERR_CRC : ERR_NONE;
|
case SC_REGISTER: return dbg_cpu0_read_ctrl(adr, (unsigned char*)data) ?
|
case SC_REGISTER: return dbg_cpu0_read_ctrl(adr, (unsigned char*)data) ?
|
ERR_CRC : ERR_NONE;
|
ERR_CRC : ERR_NONE;
|
case SC_WISHBONE: return dbg_wb_read32(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_WISHBONE: return dbg_wb_read32(adr, data) ? ERR_CRC : ERR_NONE;
|
case SC_TRACE: *data = 0; return 0;
|
case SC_TRACE: *data = 0; return 0;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
Line 3560... |
Line 3560... |
#endif
|
#endif
|
|
|
if (DEBUG_CMDS) printf("rb %d\n", gdb_chain);
|
if (DEBUG_CMDS) printf("rb %d\n", gdb_chain);
|
|
|
switch (gdb_chain) {
|
switch (gdb_chain) {
|
case SC_WISHBONE:
|
case SC_RISC_DEBUG: return dbg_cpu0_read(adr, data, len) ? ERR_CRC : ERR_NONE;
|
{
|
case SC_WISHBONE: return dbg_wb_read_block32(adr, data, len) ? ERR_CRC : ERR_NONE;
|
return dbg_wb_read_block32(adr, data, len) ? ERR_CRC : ERR_NONE;
|
|
}
|
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
}
|
}
|
}
|
}
|
|
|
int gdb_write_block(uint32_t adr, uint32_t *data, int len) {
|
int gdb_write_block(uint32_t adr, uint32_t *data, int len) {
|
Line 3577... |
Line 3576... |
adr = adr & ~OR32_LINUX_VM_MASK;
|
adr = adr & ~OR32_LINUX_VM_MASK;
|
#endif
|
#endif
|
|
|
if (DEBUG_CMDS) printf("wb %d\n", gdb_chain);
|
if (DEBUG_CMDS) printf("wb %d\n", gdb_chain);
|
switch (gdb_chain) {
|
switch (gdb_chain) {
|
case SC_WISHBONE: return dbg_wb_write_block32(adr, data, len) ?
|
case SC_RISC_DEBUG: return dbg_cpu0_write(adr, data, (uint32_t) len) ? ERR_CRC : ERR_NONE;
|
ERR_CRC : ERR_NONE;
|
case SC_WISHBONE: return dbg_wb_write_block32(adr, data, len) ? ERR_CRC : ERR_NONE;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
default: return JTAG_PROXY_INVALID_CHAIN;
|
}
|
}
|
}
|
}
|
|
|
int gdb_set_chain(int chain) {
|
int gdb_set_chain(int chain) {
|