- refactored debugger setup from <BOARD_NAME>board to debugger

git-svn-id: http://moon:8086/svn/mips@186 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2021-11-22 16:34:56 +00:00
parent 34bd764372
commit 026b7c322e
3 changed files with 10 additions and 89 deletions
+5 -2
View File
@@ -11,8 +11,8 @@ DEBUGGER ?= mips
include ../../make/mips_lib.mk include ../../make/mips_lib.mk
OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o mips_ps2.o mips_gfx.o screen.o) OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o mips_ps2.o mips_gfx.o screen.o debugger.o)
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o) OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o $(DBG_OBJ) console.o uart.o board.o gpio.o debugger.o)
OBJS-sim=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o console.o uart.o board.o gpio.o) OBJS-sim=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o console.o uart.o board.o gpio.o)
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
@@ -26,6 +26,9 @@ $(BUILD_DIR)/%.o : %.S
$(BUILD_DIR)/board.o : boards/$(BOARD)/board.c $(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
$(CC) $(CFLAGS) -G 0 -c -o $@ $< $(CC) $(CFLAGS) -G 0 -c -o $@ $<
$(BUILD_DIR)/debugger.o : boards/debugger.c
$(CC) $(CFLAGS) -G 0 -c -o $@ $<
$(BUILD_DIR)/libsys.a: $(OBJS-$(BOARD)) $(BUILD_DIR)/libsys.a: $(OBJS-$(BOARD))
$(AR) -r $(BUILD_DIR)/libsys.a $(OBJS-$(BOARD)) $(AR) -r $(BUILD_DIR)/libsys.a $(OBJS-$(BOARD))
$(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/startup.o asm/startup.S $(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/startup.o asm/startup.S
+2 -60
View File
@@ -6,36 +6,13 @@
#include <stddef.h> #include <stddef.h>
#include "board.h" #include "board.h"
#include "../debugger.h"
#include "../../irq.h" #include "../../irq.h"
#include "../../uart.h" #include "../../uart.h"
#include "../../console.h" #include "../../console.h"
#include "../../asm/regdef.h" #include "../../asm/regdef.h"
#include "../../syscalls.h" #include "../../syscalls.h"
#ifdef WITH_ROM_DEBUGGER
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01fc0;
#else
#ifdef WITH_GDB_STUB
extern void handle_exception (unsigned long *registers);
#else
extern int dbg_handler(struct xcptcontext * xcp);
#endif
int dbg_stub(struct xcptcontext * xcp) __attribute__ ((section (".dbg_stub"))) __attribute__ ((used));
int dbg_stub(struct xcptcontext * xcp)
{
#ifdef WITH_GDB_STUB
handle_exception((unsigned long *)xcp);
return 0;
#else
return dbg_handler(xcp);
#endif
}
const fp_xcpt_t dbg_func = (fp_xcpt_t)dbg_stub;
#endif
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
@@ -64,38 +41,6 @@ const con_if_t con_if =
con_if_entry, ARRAYSIZE(con_if_entry) con_if_entry, ARRAYSIZE(con_if_entry)
}; };
void dbg_uart_isr(struct xcptcontext *xcp)
{
if(SYS_UART_BIT_RX_AVAIL & *uart_if[UART_DEBUGGER].pCTRL)
{
char c = *uart_if[UART_DEBUGGER].pDATA;
if (c == 3)
{
dbg_func(xcp);
}
}
}
void dbg_uart_setup()
{
const#include "../../syscalls.h" int UART_INT = SYS_INT_UART1;
*uart_if[UART_DEBUGGER].pCTRL = SYS_UART_BIT_RX_INTEN;
interrupt_register(UART_INT, dbg_uart_isr);
interrupt_enable(UART_INT);
}
void dbg_init()
{
xcpt_register(EXC_ADEL, dbg_func);
xcpt_register(EXC_ADES, dbg_func);
xcpt_register(EXC_IBE, dbg_func);
xcpt_register(EXC_DBE, dbg_func);
xcpt_register(EXC_BP, dbg_func);
xcpt_register(EXC_RI, dbg_func);
xcpt_register(EXC_CPU, dbg_func);
xcpt_register(EXC_OV, dbg_func);
}
void board_init(void) void board_init(void)
{ {
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL; uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
@@ -109,11 +54,8 @@ void board_init(void)
// Setup syscall support // Setup syscall support
syscalls_init(); syscalls_init();
// Setup Uart ISR
dbg_uart_setup();
// Setup debugger // Setup debugger
dbg_init(); debugger_init();
// Setup interrupt support // Setup interrupt support
interrupt_init(); interrupt_init();
+3 -27
View File
@@ -6,27 +6,18 @@
#include <stddef.h> #include <stddef.h>
#include "board.h" #include "board.h"
#include "../debugger.h"
#include "../../irq.h" #include "../../irq.h"
#include "../../uart.h" #include "../../uart.h"
#include "../../console.h" #include "../../console.h"
#include "../../asm/regdef.h" #include "../../asm/regdef.h"
#include "../../syscalls.h" #include "../../syscalls.h"
// --------------------------------------------------------------------------------- #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
// Debugger
// ---------------------------------------------------------------------------------
#ifdef WITH_ROM_DEBUGGER
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01fc0;
#else
extern int dbg_handler(struct xcptcontext * xcp);
const fp_xcpt_t dbg_func = (fp_xcpt_t)dbg_handler;
#endif
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
// Uart // Uart
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
const uart_if_t uart_if[] = const uart_if_t uart_if[] =
{ {
{(uint32_t*)SYS_UART0_STAT, (uint32_t*)SYS_UART0_DATA, (uint32_t*)SYS_UART0_BAUD}, {(uint32_t*)SYS_UART0_STAT, (uint32_t*)SYS_UART0_DATA, (uint32_t*)SYS_UART0_BAUD},
@@ -50,21 +41,6 @@ const con_if_t con_if =
con_if_entry, ARRAYSIZE(con_if_entry) con_if_entry, ARRAYSIZE(con_if_entry)
}; };
void dbg_init()
{
interrupt_register(2, dbg_func);
interrupt_enable(2);
xcpt_register(EXC_ADEL, dbg_func);
xcpt_register(EXC_ADES, dbg_func);
xcpt_register(EXC_IBE, dbg_func);
xcpt_register(EXC_DBE, dbg_func);
xcpt_register(EXC_BP, dbg_func);
xcpt_register(EXC_RI, dbg_func);
xcpt_register(EXC_CPU, dbg_func);
xcpt_register(EXC_OV, dbg_func);
}
void board_init(void) void board_init(void)
{ {
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL; uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
@@ -79,7 +55,7 @@ void board_init(void)
syscalls_init(); syscalls_init();
// Setup debugger // Setup debugger
dbg_init(); debugger_init();
// Setup interrupt support // Setup interrupt support
interrupt_init(); interrupt_init();