- added and use gdb-stub

git-svn-id: http://moon:8086/svn/mips@87 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-16 19:25:08 +00:00
parent 07d42195cf
commit b23ccf5a8c
4 changed files with 56 additions and 55 deletions
+44 -34
View File
@@ -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;
}