- 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:
2017-01-22 14:30:49 +00:00
parent e86064fd65
commit 273b7a6a79
7 changed files with 82 additions and 17 deletions
+20 -4
View File
@@ -5,14 +5,24 @@
BOARD ?= ml402
TLB ?= no
ENDIANESS ?= eb
DEBUGGER ?= gdb
ifeq ($(ENDIANESS),el)
ENDIAN_FLAGS=-EL
else
ENDIAN_FLAGS=-EB
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
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
OBJS-ml402=$(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 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 $(DBG_OBJ))
$(BUILD_DIR)/cop0.o : ../libsys/cop0.c
$(CC) $(CFLAGS) -c -o $@ $<
@@ -50,6 +60,12 @@ $(BUILD_DIR)/uart.o : ../libsys/uart.c
$(BUILD_DIR)/board.o : boards/$(BOARD)/board.c
$(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
$(CC) $(CFLAGS) -c -o $@ $<
+7 -2
View File
@@ -12,9 +12,14 @@
#ifdef WITH_DEBUGGER
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)
{
#ifdef WITH_GDB_STUB
+1 -1
View File
@@ -21,7 +21,7 @@ SECTIONS
*(.ktext)
*(.text*)
*(.rodata*)
. = ORIGIN(rom) + LENGTH(rom) - 0x100;
. = ORIGIN(rom) + LENGTH(rom) - 0x40;
*(.dbg_stub*)
} > rom
+1 -1
View File
@@ -20,7 +20,7 @@ int gdb_stub(struct xcptcontext * xcp)
return 0;
}
#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
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
#endif
+1 -1
View File
@@ -20,7 +20,7 @@ int gdb_stub(struct xcptcontext * xcp)
return 0;
}
#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
const fp_xcpt_t dbg_func = (fp_xcpt_t)gdb_stub;
#endif
+17 -4
View File
@@ -120,16 +120,29 @@ void dbg_strcpy(char *pDst, const char *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)
{
*(pData++) = (char)value;
*(dst++) = (char)value;
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
View File
@@ -58,7 +58,6 @@ static bp_t mgmt_bp_ru[2];
static int g_is_ss;
static int g_bp_count;
#if 1
extern void dbg_putchar(char c);
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)
{
@@ -303,7 +334,7 @@ int dbg_handler(struct xcptcontext * xcp)
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");
@@ -585,7 +616,7 @@ int dbg_handler(struct xcptcontext * xcp)
}
} while (!leave_isr);
memcpy(&xcp_last, xcp, sizeof(EXCEPTION_CONTEXT));
dbg_memcpy(&xcp_last, xcp, sizeof(EXCEPTION_CONTEXT));
return 0;
}