From 77f94b8ce566b9498f377f635f943bcba243084e Mon Sep 17 00:00:00 2001 From: Tomasz Lauda Date: Thu, 11 Jul 2019 16:04:07 +0200 Subject: [PATCH] gdb: move xtensa specific defines to arch Moves xtensa specific defines from generic code to xtensa arch. Signed-off-by: Tomasz Lauda --- .../xtensa/include/arch/gdb/xtensa-defs.h | 18 ++++-- src/gdb/gdb.c | 57 +++++++++++-------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/arch/xtensa/include/arch/gdb/xtensa-defs.h b/src/arch/xtensa/include/arch/gdb/xtensa-defs.h index 80ffe03b0..87787cd0d 100644 --- a/src/arch/xtensa/include/arch/gdb/xtensa-defs.h +++ b/src/arch/xtensa/include/arch/gdb/xtensa-defs.h @@ -12,16 +12,22 @@ #ifndef __ARCH_GDB_XTENSA_DEFS_H__ #define __ARCH_GDB_XTENSA_DEFS_H__ +#include #include #include #include -#include -#define _AREG0 256 +#define _AREG0 256 -#define STACK_SIZE 1024 -#define DEBUG_PC (EPC + XCHAL_DEBUGLEVEL) -#define DEBUG_EXCSAVE (EXCSAVE + XCHAL_DEBUGLEVEL) -#define DEBUG_PS (EPS + XCHAL_DEBUGLEVEL) +#define STACK_SIZE 1024 +#define DEBUG_PC (EPC + XCHAL_DEBUGLEVEL) +#define DEBUG_EXCSAVE (EXCSAVE + XCHAL_DEBUGLEVEL) +#define DEBUG_PS (EPS + XCHAL_DEBUGLEVEL) +#define DEBUG_WINDOWBASE WINDOWBASE +#define DEBUG_NUM_IBREAK XCHAL_NUM_IBREAK +#define DEBUG_IBREAKENABLE IBREAKENABLE +#define DEBUG_IBREAKA IBREAKA +#define DEBUG_INTENABLE INTENABLE +#define DEBUG_NUM_AREGS XCHAL_NUM_AREGS #endif /* __ARCH_GDB_XTENSA_DEFS_H__ */ diff --git a/src/gdb/gdb.c b/src/gdb/gdb.c index e2b0967ac..1ae1e6ddc 100644 --- a/src/gdb/gdb.c +++ b/src/gdb/gdb.c @@ -15,7 +15,6 @@ #include #include #include -#include #include /* local functions */ @@ -139,7 +138,7 @@ static inline int gdb_parser(void) unsigned int i; int addr; int length; - unsigned int windowbase = (4 * sregs[WINDOWBASE]); + unsigned int windowbase = (4 * sregs[DEBUG_WINDOWBASE]); request = get_packet(); /* Log any exception caused by debug exception */ @@ -173,27 +172,33 @@ static inline int gdb_parser(void) if (*request++ == ',' && hex_to_int(&request, &addr) && *request++ == ',' && hex_to_int(&request, &length) && *request == 0) { - for (i = 0; i < XCHAL_NUM_IBREAK; ++i) { - if (!(sregs[IBREAKENABLE] & (1 << i)) || - sregs[IBREAKA + i] == addr) { - sregs[IBREAKA + i] = addr; - sregs[IBREAKENABLE] |= (1 << i); - arch_gdb_write_sr((IBREAKA+i), - sregs); - arch_gdb_write_sr(IBREAKENABLE, - sregs); + for (i = 0; i < DEBUG_NUM_IBREAK; ++i) { + if (!(sregs[DEBUG_IBREAKENABLE] & + (1 << i)) || + sregs[DEBUG_IBREAKA + i] == addr) { + sregs[DEBUG_IBREAKA + i] = + addr; + sregs[DEBUG_IBREAKENABLE] |= + (1 << i); + arch_gdb_write_sr( + (DEBUG_IBREAKA + i), + sregs); + arch_gdb_write_sr( + DEBUG_IBREAKENABLE, + sregs); break; } } - if (i == XCHAL_NUM_IBREAK) { - strcpy((char *) remcom_out_buffer, - "E02"); + if (i == DEBUG_NUM_IBREAK) { + strcpy((char *)remcom_out_buffer, + "E02"); } else { strcpy((char *)remcom_out_buffer, "OK"); - sregs[INTENABLE] &= + sregs[DEBUG_INTENABLE] &= GDB_DISABLE_LOWER_INTERRUPTS_MASK; - arch_gdb_write_sr(INTENABLE, sregs); + arch_gdb_write_sr(DEBUG_INTENABLE, + sregs); } } else { strcpy((char *)remcom_out_buffer, "E01"); @@ -219,17 +224,19 @@ static inline int gdb_parser(void) case '1': if (*request++ == ',' && hex_to_int(&request, &addr) && *request++ == ',' && hex_to_int(&request, &length)) { - for (i = 0; i < XCHAL_NUM_IBREAK; ++i) { - if (sregs[IBREAKENABLE] & (1 << i) && - sregs[IBREAKA + i] == addr) { - sregs[IBREAKENABLE] + for (i = 0; i < DEBUG_NUM_IBREAK; ++i) { + if (sregs[DEBUG_IBREAKENABLE] & + (1 << i) && + sregs[DEBUG_IBREAKA + i] == addr) { + sregs[DEBUG_IBREAKENABLE] &= ~(1 << i); - arch_gdb_write_sr(IBREAKENABLE, - sregs); + arch_gdb_write_sr( + DEBUG_IBREAKENABLE, + sregs); break; } } - if (i == XCHAL_NUM_IBREAK) + if (i == DEBUG_NUM_IBREAK) strcpy((char *)remcom_out_buffer, "E02"); else @@ -274,7 +281,7 @@ static inline int gdb_parser(void) mem_to_hex(sregs + DEBUG_PC, remcom_out_buffer, 4); } else if (addr >= GDB_AREG_RANGE && - addr < (GDB_AREG_RANGE + XCHAL_NUM_AREGS)) { + addr < (GDB_AREG_RANGE + DEBUG_NUM_AREGS)) { mem_to_hex(aregs + ((addr - windowbase) & GDB_REGISTER_MASK), remcom_out_buffer, 4); @@ -308,7 +315,7 @@ static inline int gdb_parser(void) } else if (addr == GDB_PC_REG_ID) { hex_to_mem(request, sregs + DEBUG_PC, 4); } else if (addr >= GDB_AREG_RANGE && addr < - GDB_AREG_RANGE + XCHAL_NUM_AREGS) { + GDB_AREG_RANGE + DEBUG_NUM_AREGS) { hex_to_mem(request, aregs + ((addr - windowbase) & GDB_REGISTER_MASK), 4); } else if (addr >= GDB_SPEC_REG_RANGE_START &&