- use debugger from bootloader

git-svn-id: http://moon:8086/svn/mips@100 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-18 23:17:58 +00:00
parent cf233c4d81
commit 0b96f7202d
11 changed files with 103 additions and 207 deletions
+10 -57
View File
@@ -11,7 +11,7 @@
#include "../../console.h"
#include "../../regdef.h"
#define DEBUGGER gdb_stub
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
extern uart_if_t uart_if[];
@@ -32,18 +32,6 @@ const con_if_t con_if =
};
static uart_if_t const *dbg_uart = NULL;
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;
extern int dbg_handler(struct xcptcontext * xcp);
extern void handle_exception (unsigned long *registers);
int gdb_stub(struct xcptcontext * xcp)
{
handle_exception((unsigned long *)xcp);
return 0;
}
void dbg_uart_isr(struct xcptcontext *xcp)
{
@@ -52,7 +40,7 @@ void dbg_uart_isr(struct xcptcontext *xcp)
char c = *dbg_uart->pDATA;
if (c == 3)
{
DEBUGGER(xcp);
dbg_func(xcp);
}
}
}
@@ -67,50 +55,16 @@ void dbg_uart_setup()
interrupt_enable(UART_INT);
}
inline void _dbg_writechar(uart_if_t const *pUart, char c)
{
while((SYS_UART_BIT_TX_HALFFULL & *pUart->pCTRL) != 0);
*pUart->pDATA = (uint32_t)c;
}
inline char _dbg_readchar(uart_if_t const *pUart)
{
// busy read
while(!(SYS_UART_BIT_RX_AVAIL & *pUart->pCTRL))
{
(*pGpioData) = (led_count++) >> 16;
}
led_count = 0;
return (*pUart->pDATA & 0xFF);
}
void dbg_putchar(char c)
{
if (c == 0x0A)
{
_dbg_writechar(dbg_uart, 0x0D);
}
_dbg_writechar(dbg_uart, c);
}
char dbg_getchar()
{
return (char)_dbg_readchar(dbg_uart);
}
void dbg_init()
{
xcpt_register(EXC_ADEL, DEBUGGER);
xcpt_register(EXC_ADES, DEBUGGER);
xcpt_register(EXC_IBE, DEBUGGER);
xcpt_register(EXC_DBE, DEBUGGER);
xcpt_register(EXC_BP, DEBUGGER);
xcpt_register(EXC_RI, DEBUGGER);
xcpt_register(EXC_CPU, DEBUGGER);
xcpt_register(EXC_OV, DEBUGGER);
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)
@@ -133,5 +87,4 @@ void board_init(void)
interrupt_init();
// Do some initializations here
*pGpioDir = 0xFF;
}
+2
View File
@@ -15,6 +15,8 @@
#define BOARD_H
#define CPU_FREQ_HZ 50000000
#define UART_STDIO 0
#define UART_DEBUGGER 1
// ---------------------------------------------------------
// IRQs