diff --git a/src/libsys/Makefile b/src/libsys/Makefile index f906bf8..2654b23 100644 --- a/src/libsys/Makefile +++ b/src/libsys/Makefile @@ -11,8 +11,8 @@ DEBUGGER ?= mips 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-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-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 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) all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a @@ -26,6 +26,9 @@ $(BUILD_DIR)/%.o : %.S $(BUILD_DIR)/board.o : boards/$(BOARD)/board.c $(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)) $(AR) -r $(BUILD_DIR)/libsys.a $(OBJS-$(BOARD)) $(CC) $(CFLAGS) -G 0 -c -o $(BUILD_DIR)/startup.o asm/startup.S diff --git a/src/libsys/boards/denano/board.c b/src/libsys/boards/denano/board.c index 05380c1..39d708b 100644 --- a/src/libsys/boards/denano/board.c +++ b/src/libsys/boards/denano/board.c @@ -6,36 +6,13 @@ #include #include "board.h" +#include "../debugger.h" #include "../../irq.h" #include "../../uart.h" #include "../../console.h" #include "../../asm/regdef.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])) // --------------------------------------------------------------------------------- @@ -64,38 +41,6 @@ const con_if_t con_if = 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) { uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL; @@ -109,11 +54,8 @@ void board_init(void) // Setup syscall support syscalls_init(); - // Setup Uart ISR - dbg_uart_setup(); - // Setup debugger - dbg_init(); + debugger_init(); // Setup interrupt support interrupt_init(); diff --git a/src/libsys/boards/ml402/board.c b/src/libsys/boards/ml402/board.c index 6e3e725..1d6871a 100644 --- a/src/libsys/boards/ml402/board.c +++ b/src/libsys/boards/ml402/board.c @@ -6,27 +6,18 @@ #include #include "board.h" +#include "../debugger.h" #include "../../irq.h" #include "../../uart.h" #include "../../console.h" #include "../../asm/regdef.h" #include "../../syscalls.h" -// --------------------------------------------------------------------------------- -// 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 +#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) // --------------------------------------------------------------------------------- // Uart // --------------------------------------------------------------------------------- -#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) - const uart_if_t uart_if[] = { {(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) }; -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) { uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL; @@ -79,7 +55,7 @@ void board_init(void) syscalls_init(); // Setup debugger - dbg_init(); + debugger_init(); // Setup interrupt support interrupt_init();