- bootloader prepared for use mit mips debugger
- changed address of debugger entry - mips_dbg: no use om memset and memcpy git-svn-id: http://moon:8086/svn/mips@120 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+19
-3
@@ -5,6 +5,7 @@
|
|||||||
BOARD ?= ml402
|
BOARD ?= ml402
|
||||||
TLB ?= no
|
TLB ?= no
|
||||||
ENDIANESS ?= eb
|
ENDIANESS ?= eb
|
||||||
|
DEBUGGER ?= gdb
|
||||||
|
|
||||||
ifeq ($(ENDIANESS),el)
|
ifeq ($(ENDIANESS),el)
|
||||||
ENDIAN_FLAGS=-EL
|
ENDIAN_FLAGS=-EL
|
||||||
@@ -12,7 +13,16 @@ else
|
|||||||
ENDIAN_FLAGS=-EB
|
ENDIAN_FLAGS=-EB
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS=$(ENDIAN_FLAGS) -Os -flto -Wl,-M -I. -I../libsys -msoft-float -march=r3000 -G0 -I../libsys/boards/$(BOARD) -D$(BOARD) -DWITH_DEBUGGER -DWITH_GDB_STUB
|
ifeq ($(DEBUGGER),gdb)
|
||||||
|
DBG_FLAGS := -DWITH_DEBUGGER -DWITH_GDB_STUB
|
||||||
|
DBG_OBJ := gdb_stub.o
|
||||||
|
endif
|
||||||
|
ifeq ($(DEBUGGER),mips)
|
||||||
|
DBG_FLAGS := -DWITH_DEBUGGER
|
||||||
|
DBG_OBJ := mips_dbg.o mips_dis.o
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS=$(ENDIAN_FLAGS) -Os -flto -Wl,-M -I. -I../libsys -msoft-float -march=r3000 -G0 -I../libsys/boards/$(BOARD) -D$(BOARD) $(DBG_FLAGS)
|
||||||
LFLAGS=$(ENDIAN_FLAGS) -Os -flto -nostartfiles -nodefaultlibs -nostdlib
|
LFLAGS=$(ENDIAN_FLAGS) -Os -flto -nostartfiles -nodefaultlibs -nostdlib
|
||||||
|
|
||||||
ifeq ($(TLB),yes)
|
ifeq ($(TLB),yes)
|
||||||
@@ -38,8 +48,8 @@ ROMGEN=$(MIPS_HOME)/tools/romgen
|
|||||||
|
|
||||||
all: $(BUILD_DIR) $(BUILD_DIR)/bootloader.elf $(BUILD_DIR)/bootloader_with_flash.elf
|
all: $(BUILD_DIR) $(BUILD_DIR)/bootloader.elf $(BUILD_DIR)/bootloader_with_flash.elf
|
||||||
|
|
||||||
OBJS-ml402=$(addprefix $(BUILD_DIR)/, startup.o kernel.o cop0.o libsys.o srec.o board.o uart.o gdb_stub.o)
|
OBJS-ml402=$(addprefix $(BUILD_DIR)/, startup.o kernel.o cop0.o libsys.o srec.o board.o uart.o $(DBG_OBJ))
|
||||||
OBJS-denano=$(addprefix $(BUILD_DIR)/, startup.o kernel.o cop0.o libsys.o srec.o board.o uart.o gdb_stub.o)
|
OBJS-denano=$(addprefix $(BUILD_DIR)/, startup.o kernel.o cop0.o libsys.o srec.o board.o uart.o $(DBG_OBJ))
|
||||||
|
|
||||||
$(BUILD_DIR)/cop0.o : ../libsys/cop0.c
|
$(BUILD_DIR)/cop0.o : ../libsys/cop0.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
@@ -50,6 +60,12 @@ $(BUILD_DIR)/uart.o : ../libsys/uart.c
|
|||||||
$(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
|
$(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
$(BUILD_DIR)/mips_dbg.o : ../libsys/mips_dbg.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
$(BUILD_DIR)/mips_dis.o : ../libsys/mips_dis.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(BUILD_DIR)/gdb_stub.o : ../libsys/gdb_stub.c
|
$(BUILD_DIR)/gdb_stub.o : ../libsys/gdb_stub.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,14 @@
|
|||||||
|
|
||||||
#ifdef WITH_DEBUGGER
|
#ifdef WITH_DEBUGGER
|
||||||
extern uart_if_t uart_if[];
|
extern uart_if_t uart_if[];
|
||||||
extern void handle_exception (unsigned long *registers);
|
|
||||||
extern int dbg_stub(struct xcptcontext * xcp) __attribute__ ((section (".dbg_stub"))) __attribute__ ((used));
|
|
||||||
|
|
||||||
|
#ifdef WITH_GDB_STUB
|
||||||
|
extern void handle_exception (unsigned long *registers);
|
||||||
|
#else
|
||||||
|
extern int dbg_handler(struct xcptcontext * xcp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int dbg_stub(struct xcptcontext * xcp) __attribute__ ((section (".dbg_stub"))) __attribute__ ((used));
|
||||||
int dbg_stub(struct xcptcontext * xcp)
|
int dbg_stub(struct xcptcontext * xcp)
|
||||||
{
|
{
|
||||||
#ifdef WITH_GDB_STUB
|
#ifdef WITH_GDB_STUB
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ SECTIONS
|
|||||||
*(.ktext)
|
*(.ktext)
|
||||||
*(.text*)
|
*(.text*)
|
||||||
*(.rodata*)
|
*(.rodata*)
|
||||||
. = ORIGIN(rom) + LENGTH(rom) - 0x100;
|
. = ORIGIN(rom) + LENGTH(rom) - 0x40;
|
||||||
*(.dbg_stub*)
|
*(.dbg_stub*)
|
||||||
} > rom
|
} > rom
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ int gdb_stub(struct xcptcontext * xcp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef WITH_ROM_GDBSTUB
|
#ifdef WITH_ROM_GDBSTUB
|
||||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01fc0;
|
||||||
#else
|
#else
|
||||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ int gdb_stub(struct xcptcontext * xcp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef WITH_ROM_GDBSTUB
|
#ifdef WITH_ROM_GDBSTUB
|
||||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01f00;
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)0xbfc01fc0;
|
||||||
#else
|
#else
|
||||||
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
|
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+17
-4
@@ -120,16 +120,29 @@ void dbg_strcpy(char *pDst, const char *pSrc)
|
|||||||
*pDst = *pSrc;
|
*pDst = *pSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* dbg_memset(void *pBuffer, int value, size_t size)
|
void* dbg_memset(void *pDst, int value, size_t size)
|
||||||
{
|
{
|
||||||
char *pData = (char*)pBuffer;
|
char *dst = (char*)pDst;
|
||||||
|
|
||||||
while(size)
|
while(size)
|
||||||
{
|
{
|
||||||
*(pData++) = (char)value;
|
*(dst++) = (char)value;
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
return (void*)pData;
|
return (void*)dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* dbg_memcpy(void *pDst, const void *pSrc, size_t size )
|
||||||
|
{
|
||||||
|
char *dst = (char*)pDst;
|
||||||
|
char *src = (char*)pSrc;
|
||||||
|
|
||||||
|
while(size)
|
||||||
|
{
|
||||||
|
*(dst++) = *(src++);
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
return (void*)dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
+35
-4
@@ -58,7 +58,6 @@ static bp_t mgmt_bp_ru[2];
|
|||||||
static int g_is_ss;
|
static int g_is_ss;
|
||||||
static int g_bp_count;
|
static int g_bp_count;
|
||||||
|
|
||||||
#if 1
|
|
||||||
extern void dbg_putchar(char c);
|
extern void dbg_putchar(char c);
|
||||||
extern char dbg_getchar();
|
extern char dbg_getchar();
|
||||||
|
|
||||||
@@ -148,7 +147,39 @@ void dbg_print_word_d(int word)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
void dbg_strcpy(char *pDst, const char *pSrc)
|
||||||
|
{
|
||||||
|
while(*pSrc)
|
||||||
|
{
|
||||||
|
*(pDst++) = *(pSrc++);
|
||||||
|
}
|
||||||
|
*pDst = *pSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* dbg_memset(void *pDst, int value, size_t size)
|
||||||
|
{
|
||||||
|
char *dst = (char*)pDst;
|
||||||
|
|
||||||
|
while(size)
|
||||||
|
{
|
||||||
|
*(dst++) = (char)value;
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
return (void*)dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* dbg_memcpy(void *pDst, const void *pSrc, size_t size )
|
||||||
|
{
|
||||||
|
char *dst = (char*)pDst;
|
||||||
|
char *src = (char*)pSrc;
|
||||||
|
|
||||||
|
while(size)
|
||||||
|
{
|
||||||
|
*(dst++) = *(src++);
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
return (void*)dst;
|
||||||
|
}
|
||||||
|
|
||||||
int IsBreak(uint32_t instr)
|
int IsBreak(uint32_t instr)
|
||||||
{
|
{
|
||||||
@@ -303,7 +334,7 @@ int dbg_handler(struct xcptcontext * xcp)
|
|||||||
|
|
||||||
if (g_state = STATE_INIT)
|
if (g_state = STATE_INIT)
|
||||||
{
|
{
|
||||||
memset(&xcp_last, 0, sizeof(EXCEPTION_CONTEXT));
|
dbg_memset(&xcp_last, 0, sizeof(EXCEPTION_CONTEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg_puts_d("\n");dbg_puts_d(g_state_names[g_state]);dbg_puts_d("\n");
|
dbg_puts_d("\n");dbg_puts_d(g_state_names[g_state]);dbg_puts_d("\n");
|
||||||
@@ -585,7 +616,7 @@ int dbg_handler(struct xcptcontext * xcp)
|
|||||||
}
|
}
|
||||||
} while (!leave_isr);
|
} while (!leave_isr);
|
||||||
|
|
||||||
memcpy(&xcp_last, xcp, sizeof(EXCEPTION_CONTEXT));
|
dbg_memcpy(&xcp_last, xcp, sizeof(EXCEPTION_CONTEXT));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user