- 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
+17 -47
View File
@@ -5,82 +5,52 @@
*/
#include <stddef.h>
#include "../../../libsys/boards/ml402/board.h"
#include <board.h>
#include "../../../libsys/uart.h"
#include "../../../libsys/irq.h"
#define DEBUGGER gdb_stub
#include "../../../libsys/uart.h"
extern uart_if_t uart_if[];
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
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) __attribute__ ((section (".gdb")));
int gdb_stub(struct xcptcontext * xcp)
{
// handle_exception((unsigned long *)xcp);
handle_exception((unsigned long *)xcp);
return 0;
}
void dbg_uart_isr(struct xcptcontext *xcp)
{
if(SYS_UART_BIT_RX_AVAIL & *dbg_uart->pCTRL)
{
char c = *dbg_uart->pDATA;
if (c == 3)
{
DEBUGGER(xcp);
}
}
}
void dbg_uart_setup()
{
const int UART_INT = SYS_INT_UART;
dbg_uart = (uart_if_t*)&uart_if[1];
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
}
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;
UART_writechar(pUart, 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);
int c;
// busy read
do
{
c = UART_readchar(pUart);
} while(c < 0);
return (char)c;
}
void dbg_putchar(char c)
{
if (c == 0x0A)
{
_dbg_writechar(dbg_uart, 0x0D);
_dbg_writechar(&uart_if[UART_DEBUGGER], 0x0D);
}
_dbg_writechar(dbg_uart, c);
_dbg_writechar(&uart_if[UART_DEBUGGER], c);
}
char dbg_getchar()
{
return (char)_dbg_readchar(dbg_uart);
return (char)_dbg_readchar(&uart_if[UART_DEBUGGER]);
}
void board_init(void)