- added and use gdb-stub
git-svn-id: http://moon:8086/svn/mips@87 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ OBJCOPY=mipsel-elf-objcopy
|
||||
FLASHGEN=flashgen
|
||||
|
||||
OBJS-ml402=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o mips_ps2.o mips_gfx.o console.o screen.o uart.o board.o gpio.o)
|
||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o)
|
||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, libsys.o xcpt.o syscalls.o cop0.o irq.o mips_dbg.o mips_dis.o console.o uart.o board.o gdb_stub.o)
|
||||
|
||||
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
|
||||
|
||||
|
||||
@@ -31,41 +31,13 @@ static volatile uint32_t *pGpioData = (uint32_t*)SYS_GPIO_0_DATA;
|
||||
static volatile uint32_t *pGpioDir = (uint32_t*)SYS_GPIO_0_DIR;
|
||||
static uint32_t led_count = 0;
|
||||
|
||||
void dbg_uart_setup();
|
||||
extern int dbg_handler(struct xcptcontext * xcp);
|
||||
extern void handle_exception (unsigned long *registers);
|
||||
|
||||
void board_init(void)
|
||||
int gdb_stub(struct xcptcontext * xcp)
|
||||
{
|
||||
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
|
||||
|
||||
// Disable timers
|
||||
*pITIM_ctrl = 0;
|
||||
|
||||
// Setup syscall support
|
||||
syscalls_init();
|
||||
|
||||
// Setup Uart ISR
|
||||
dbg_uart_setup();
|
||||
|
||||
// Setup debugger
|
||||
dbg_init();
|
||||
|
||||
// Setup interrupt support
|
||||
interrupt_init();
|
||||
|
||||
// Do some initializations here
|
||||
*pGpioDir = 0xFF;
|
||||
}
|
||||
|
||||
extern void dbg_handler(struct xcptcontext * xcp);
|
||||
void dbg_uart_isr(struct xcptcontext *xcp);
|
||||
void dbg_uart_setup()
|
||||
{
|
||||
const int UART_INT = SYS_INT_UART1;
|
||||
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
|
||||
|
||||
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
|
||||
interrupt_register(UART_INT, dbg_uart_isr);
|
||||
interrupt_enable(UART_INT);
|
||||
handle_exception((unsigned long *)xcp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dbg_uart_isr(struct xcptcontext *xcp)
|
||||
@@ -75,11 +47,21 @@ void dbg_uart_isr(struct xcptcontext *xcp)
|
||||
char c = *dbg_uart->pDATA;
|
||||
if (c == 3)
|
||||
{
|
||||
dbg_handler(xcp);
|
||||
gdb_stub(xcp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dbg_uart_setup()
|
||||
{
|
||||
const int UART_INT = SYS_INT_UART1;
|
||||
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
|
||||
|
||||
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
|
||||
interrupt_register(UART_INT, dbg_uart_isr);
|
||||
interrupt_enable(UART_INT);
|
||||
}
|
||||
|
||||
inline void _dbg_writechar(uart_if_t const *pUart, char c)
|
||||
{
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pUart->pCTRL) != 0);
|
||||
@@ -113,3 +95,31 @@ char dbg_getchar()
|
||||
{
|
||||
return (char)_dbg_readchar(dbg_uart);
|
||||
}
|
||||
|
||||
void dbg_init()
|
||||
{
|
||||
xcpt_register(EXC_BP, gdb_stub);
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
|
||||
|
||||
// Disable timers
|
||||
*pITIM_ctrl = 0;
|
||||
|
||||
// Setup syscall support
|
||||
syscalls_init();
|
||||
|
||||
// Setup Uart ISR
|
||||
dbg_uart_setup();
|
||||
|
||||
// Setup debugger
|
||||
dbg_init();
|
||||
|
||||
// Setup interrupt support
|
||||
interrupt_init();
|
||||
|
||||
// Do some initializations here
|
||||
*pGpioDir = 0xFF;
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ LEAF(_xcpt_handler)
|
||||
|
||||
/* allocate exception stack frame (on 8-byte boundary) */
|
||||
li k1, XCP_SIZE
|
||||
subu k1, sp, k1
|
||||
srl k1, 3 /* shift right/left -> alligned on boundary */
|
||||
subu k1, sp, k1
|
||||
srl k1, 3 /* shift right/left -> alligned on boundary */
|
||||
sll k1, 3
|
||||
|
||||
/* save enough registers to get by */
|
||||
|
||||
+9
-18
@@ -42,10 +42,9 @@ enum
|
||||
STATE_NUM_ENTRIES
|
||||
};
|
||||
|
||||
static int g_state;
|
||||
static int g_state = STATE_INIT;
|
||||
static char *g_state_names[STATE_NUM_ENTRIES] = {"Init", "Run", "Single step", "Precedure step"};
|
||||
|
||||
|
||||
typedef struct _sbp_t
|
||||
{
|
||||
uint32_t *pAddr;
|
||||
@@ -285,7 +284,7 @@ void singlestep(struct xcptcontext * xcp, uint32_t *pAddr_curr, uint32_t is_bran
|
||||
|
||||
}
|
||||
|
||||
void dbg_handler(struct xcptcontext * xcp)
|
||||
int dbg_handler(struct xcptcontext * xcp)
|
||||
{
|
||||
|
||||
uint32_t bp_addr, bp_index = 0, branch_addr, reg, result, bp_type;
|
||||
@@ -302,8 +301,13 @@ void dbg_handler(struct xcptcontext * xcp)
|
||||
pAddr_prev = pAddr_curr - 1;
|
||||
pAddr_next = pAddr_curr + 1;
|
||||
|
||||
if (g_state = STATE_INIT)
|
||||
{
|
||||
memset(&xcp_last, 0, sizeof(EXCEPTION_CONTEXT));
|
||||
}
|
||||
|
||||
dbg_puts_d("\n");dbg_puts_d(g_state_names[g_state]);dbg_puts_d("\n");
|
||||
|
||||
|
||||
if (IsBreak(*pAddr_curr))
|
||||
{
|
||||
bp_type = BreakGetType(*pAddr_curr);
|
||||
@@ -582,19 +586,6 @@ void dbg_handler(struct xcptcontext * xcp)
|
||||
} while (!leave_isr);
|
||||
|
||||
memcpy(&xcp_last, xcp, sizeof(EXCEPTION_CONTEXT));
|
||||
}
|
||||
|
||||
int debug_break(struct xcptcontext * xcp)
|
||||
{
|
||||
dbg_handler(xcp);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void dbg_init(void)
|
||||
{
|
||||
memset(&xcp_last, 0, sizeof(EXCEPTION_CONTEXT));
|
||||
g_state = STATE_INIT;
|
||||
xcpt_register(EXC_BP, debug_break);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user