gdb: move xtensa specific defines to arch

Moves xtensa specific defines from generic code
to xtensa arch.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
Tomasz Lauda 2019-07-11 16:04:07 +02:00 committed by Tomasz Lauda
parent a990c611c4
commit 77f94b8ce5
2 changed files with 44 additions and 31 deletions

View File

@ -12,16 +12,22 @@
#ifndef __ARCH_GDB_XTENSA_DEFS_H__ #ifndef __ARCH_GDB_XTENSA_DEFS_H__
#define __ARCH_GDB_XTENSA_DEFS_H__ #define __ARCH_GDB_XTENSA_DEFS_H__
#include <config.h>
#include <xtensa/specreg.h> #include <xtensa/specreg.h>
#include <xtensa/config/core-isa.h> #include <xtensa/config/core-isa.h>
#include <xtensa/corebits.h> #include <xtensa/corebits.h>
#include <config.h>
#define _AREG0 256 #define _AREG0 256
#define STACK_SIZE 1024 #define STACK_SIZE 1024
#define DEBUG_PC (EPC + XCHAL_DEBUGLEVEL) #define DEBUG_PC (EPC + XCHAL_DEBUGLEVEL)
#define DEBUG_EXCSAVE (EXCSAVE + XCHAL_DEBUGLEVEL) #define DEBUG_EXCSAVE (EXCSAVE + XCHAL_DEBUGLEVEL)
#define DEBUG_PS (EPS + 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__ */ #endif /* __ARCH_GDB_XTENSA_DEFS_H__ */

View File

@ -15,7 +15,6 @@
#include <sof/string.h> #include <sof/string.h>
#include <signal.h> #include <signal.h>
#include <stdint.h> #include <stdint.h>
#include <xtensa/xtruntime.h>
#include <sof/drivers/interrupt.h> #include <sof/drivers/interrupt.h>
/* local functions */ /* local functions */
@ -139,7 +138,7 @@ static inline int gdb_parser(void)
unsigned int i; unsigned int i;
int addr; int addr;
int length; int length;
unsigned int windowbase = (4 * sregs[WINDOWBASE]); unsigned int windowbase = (4 * sregs[DEBUG_WINDOWBASE]);
request = get_packet(); request = get_packet();
/* Log any exception caused by debug exception */ /* Log any exception caused by debug exception */
@ -173,27 +172,33 @@ static inline int gdb_parser(void)
if (*request++ == ',' && hex_to_int(&request, &addr) && if (*request++ == ',' && hex_to_int(&request, &addr) &&
*request++ == ',' && hex_to_int(&request, &length) *request++ == ',' && hex_to_int(&request, &length)
&& *request == 0) { && *request == 0) {
for (i = 0; i < XCHAL_NUM_IBREAK; ++i) { for (i = 0; i < DEBUG_NUM_IBREAK; ++i) {
if (!(sregs[IBREAKENABLE] & (1 << i)) || if (!(sregs[DEBUG_IBREAKENABLE] &
sregs[IBREAKA + i] == addr) { (1 << i)) ||
sregs[IBREAKA + i] = addr; sregs[DEBUG_IBREAKA + i] == addr) {
sregs[IBREAKENABLE] |= (1 << i); sregs[DEBUG_IBREAKA + i] =
arch_gdb_write_sr((IBREAKA+i), addr;
sregs); sregs[DEBUG_IBREAKENABLE] |=
arch_gdb_write_sr(IBREAKENABLE, (1 << i);
sregs); arch_gdb_write_sr(
(DEBUG_IBREAKA + i),
sregs);
arch_gdb_write_sr(
DEBUG_IBREAKENABLE,
sregs);
break; break;
} }
} }
if (i == XCHAL_NUM_IBREAK) { if (i == DEBUG_NUM_IBREAK) {
strcpy((char *) remcom_out_buffer, strcpy((char *)remcom_out_buffer,
"E02"); "E02");
} else { } else {
strcpy((char *)remcom_out_buffer, "OK"); strcpy((char *)remcom_out_buffer, "OK");
sregs[INTENABLE] &= sregs[DEBUG_INTENABLE] &=
GDB_DISABLE_LOWER_INTERRUPTS_MASK; GDB_DISABLE_LOWER_INTERRUPTS_MASK;
arch_gdb_write_sr(INTENABLE, sregs); arch_gdb_write_sr(DEBUG_INTENABLE,
sregs);
} }
} else { } else {
strcpy((char *)remcom_out_buffer, "E01"); strcpy((char *)remcom_out_buffer, "E01");
@ -219,17 +224,19 @@ static inline int gdb_parser(void)
case '1': case '1':
if (*request++ == ',' && hex_to_int(&request, &addr) && if (*request++ == ',' && hex_to_int(&request, &addr) &&
*request++ == ',' && hex_to_int(&request, &length)) { *request++ == ',' && hex_to_int(&request, &length)) {
for (i = 0; i < XCHAL_NUM_IBREAK; ++i) { for (i = 0; i < DEBUG_NUM_IBREAK; ++i) {
if (sregs[IBREAKENABLE] & (1 << i) && if (sregs[DEBUG_IBREAKENABLE] &
sregs[IBREAKA + i] == addr) { (1 << i) &&
sregs[IBREAKENABLE] sregs[DEBUG_IBREAKA + i] == addr) {
sregs[DEBUG_IBREAKENABLE]
&= ~(1 << i); &= ~(1 << i);
arch_gdb_write_sr(IBREAKENABLE, arch_gdb_write_sr(
sregs); DEBUG_IBREAKENABLE,
sregs);
break; break;
} }
} }
if (i == XCHAL_NUM_IBREAK) if (i == DEBUG_NUM_IBREAK)
strcpy((char *)remcom_out_buffer, strcpy((char *)remcom_out_buffer,
"E02"); "E02");
else else
@ -274,7 +281,7 @@ static inline int gdb_parser(void)
mem_to_hex(sregs + DEBUG_PC, mem_to_hex(sregs + DEBUG_PC,
remcom_out_buffer, 4); remcom_out_buffer, 4);
} else if (addr >= GDB_AREG_RANGE && } 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) & mem_to_hex(aregs + ((addr - windowbase) &
GDB_REGISTER_MASK), GDB_REGISTER_MASK),
remcom_out_buffer, 4); remcom_out_buffer, 4);
@ -308,7 +315,7 @@ static inline int gdb_parser(void)
} else if (addr == GDB_PC_REG_ID) { } else if (addr == GDB_PC_REG_ID) {
hex_to_mem(request, sregs + DEBUG_PC, 4); hex_to_mem(request, sregs + DEBUG_PC, 4);
} else if (addr >= GDB_AREG_RANGE && addr < } else if (addr >= GDB_AREG_RANGE && addr <
GDB_AREG_RANGE + XCHAL_NUM_AREGS) { GDB_AREG_RANGE + DEBUG_NUM_AREGS) {
hex_to_mem(request, aregs + hex_to_mem(request, aregs +
((addr - windowbase) & GDB_REGISTER_MASK), 4); ((addr - windowbase) & GDB_REGISTER_MASK), 4);
} else if (addr >= GDB_SPEC_REG_RANGE_START && } else if (addr >= GDB_SPEC_REG_RANGE_START &&