- use debugger from bootloader
git-svn-id: http://moon:8086/svn/mips@100 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -38,8 +38,8 @@ ROMGEN=$(MIPS_HOME)/tools/romgen
|
||||
|
||||
all: $(BUILD_DIR) $(BUILD_DIR)/bootloader.elf $(BUILD_DIR)/bootloader_with_flash.elf
|
||||
|
||||
OBJS-ml402=$(addprefix $(BUILD_DIR)/, startup.o kernel.o libsys.o board.o uart.o)
|
||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, startup.o kernel.o libsys.o board.o uart.o)
|
||||
OBJS-ml402=$(addprefix $(BUILD_DIR)/, startup.o kernel.o libsys.o board.o uart.o gdb_stub.o)
|
||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, startup.o kernel.o libsys.o board.o uart.o gdb_stub.o)
|
||||
|
||||
$(BUILD_DIR)/uart.o : ../libsys/uart.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
@@ -47,6 +47,9 @@ $(BUILD_DIR)/uart.o : ../libsys/uart.c
|
||||
$(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/gdb_stub.o : ../libsys/gdb_stub.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/%.o : %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
@@ -5,82 +5,52 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "../../../libsys/boards/denano/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_UART1;
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -21,6 +21,8 @@ SECTIONS
|
||||
*(.ktext)
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
. = ORIGIN(rom) + 0x1F00;
|
||||
*(.gdb*)
|
||||
} > rom
|
||||
|
||||
.data ORIGIN(ram) :
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <board.h>
|
||||
#include "libsys.h"
|
||||
#include "../../uart.h"
|
||||
|
||||
@@ -143,7 +144,7 @@ char readchar(void)
|
||||
// busy read
|
||||
do
|
||||
{
|
||||
c = UART_readchar(&uart_if[0]);
|
||||
c = UART_readchar(&uart_if[UART_STDIO]);
|
||||
|
||||
} while(c < 0);
|
||||
|
||||
@@ -152,7 +153,7 @@ char readchar(void)
|
||||
|
||||
void writechar(char c)
|
||||
{
|
||||
UART_writechar(&uart_if[0], c);
|
||||
UART_writechar(&uart_if[UART_STDIO], c);
|
||||
}
|
||||
|
||||
void _putchar(char c)
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ OBJCOPY=mips-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 gdb_stub.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)
|
||||
|
||||
all: $(BUILD_DIR) $(BUILD_DIR)/libsys.a
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#define BOARD_H
|
||||
|
||||
#define CPU_FREQ_HZ 50000000
|
||||
#define UART_STDIO 0
|
||||
#define UART_DEBUGGER 1
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// IRQs
|
||||
|
||||
@@ -5,21 +5,15 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "../../irq.h"
|
||||
#include "../../mips_ps2.h"
|
||||
#include "../../mips_gfx.h"
|
||||
#include "../../screen.h"
|
||||
#include "../../uart.h"
|
||||
#include "../../console.h"
|
||||
#include "board.h"
|
||||
#include "../../regdef.h"
|
||||
|
||||
extern int dbg_handler(struct xcptcontext * xcp);
|
||||
#define DEBUGGER dbg_handler
|
||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
||||
|
||||
extern uart_if_t uart_if[];
|
||||
extern ps2_if_t ps2_if[];
|
||||
extern vga_if_t vga_if;
|
||||
|
||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
@@ -28,11 +22,8 @@ const con_if_entry_t con_if_entry[] =
|
||||
{0, "stdin", &uart_if[0], NULL, NULL, UART_readchar, NULL},
|
||||
{1, "stdout", &uart_if[0], NULL, NULL, NULL, UART_writechar},
|
||||
{2, "stderr", &uart_if[0], NULL, NULL, NULL, UART_writechar},
|
||||
{10, "UART-0", &uart_if[0], NULL, NULL, UART_readchar, UART_writechar},
|
||||
{11, "UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar},
|
||||
{20, "PS2-0", &ps2_if[0], PS2_open, PS2_close, PS2_readchar, NULL},
|
||||
{21, "PS2-1", &ps2_if[1], PS2_open, PS2_close, PS2_readchar, NULL},
|
||||
{30, "VGA-0", &vga_if, cg_open, cg_close, NULL, cg_writechar}
|
||||
{3, "UART-0", &uart_if[0], NULL, NULL, UART_readchar, UART_writechar},
|
||||
{4, "UART-1", &uart_if[1], NULL, NULL, UART_readchar, UART_writechar}
|
||||
};
|
||||
|
||||
const con_if_t con_if =
|
||||
@@ -40,59 +31,60 @@ const con_if_t con_if =
|
||||
con_if_entry, ARRAYSIZE(con_if_entry)
|
||||
};
|
||||
|
||||
void handle_debugger_int(struct xcptcontext * xcp)
|
||||
static uart_if_t const *dbg_uart = NULL;
|
||||
|
||||
void dbg_uart_isr(struct xcptcontext *xcp)
|
||||
{
|
||||
dbg_handler(xcp);
|
||||
if(SYS_UART_BIT_RX_AVAIL & *dbg_uart->pCTRL)
|
||||
{
|
||||
char c = *dbg_uart->pDATA;
|
||||
if (c == 3)
|
||||
{
|
||||
dbg_func(xcp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dbg_uart_setup()
|
||||
{
|
||||
const int UART_INT = SYS_INT_UART;
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
uint32_t volatile *pITIM_ctrl = (uint32_t*)SYS_ITIM_CTRL;
|
||||
|
||||
// Screen_clr();
|
||||
|
||||
// Disable timers
|
||||
*pITIM_ctrl = 0;
|
||||
|
||||
// Disable all VGA stuff
|
||||
// *pVGA_ctrl = 0;
|
||||
|
||||
// Initialzie syscall support
|
||||
// Setup syscall support
|
||||
syscalls_init();
|
||||
|
||||
// Initialzie interrupt support
|
||||
// Setup Uart ISR
|
||||
dbg_uart_setup();
|
||||
|
||||
// Setup debugger
|
||||
dbg_init();
|
||||
|
||||
// Setup interrupt support
|
||||
interrupt_init();
|
||||
|
||||
// Initalize debugger
|
||||
dbg_init();
|
||||
interrupt_register(2, handle_debugger_int);
|
||||
interrupt_enable(2);
|
||||
|
||||
// flush stdin
|
||||
// flush(con_getPort(0));
|
||||
|
||||
// Do some initializations here
|
||||
|
||||
}
|
||||
|
||||
void dbg_putchar(char c)
|
||||
{
|
||||
writechar(1, c);
|
||||
}
|
||||
|
||||
char dbg_getchar()
|
||||
{
|
||||
return (char)readchar(0);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#define BOARD_H
|
||||
|
||||
#define CPU_FREQ_HZ 100000000
|
||||
#define UART_STDIO 0
|
||||
#define UART_DEBUGGER 1
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// IRQs
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "libsys.h"
|
||||
#include <libsys.h>
|
||||
#include <irq.h>
|
||||
|
||||
void _exc_break(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user