- no memset and strcpy in gdb_stub
- boattloader : refactored, size optimization, nostartup, nostdlib, nodefaultlibs git-svn-id: http://moon:8086/svn/mips@119 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -13,7 +13,7 @@ else
|
|||||||
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
|
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
|
||||||
LFLAGS=$(ENDIAN_FLAGS) -Os -flto
|
LFLAGS=$(ENDIAN_FLAGS) -Os -flto -nostartfiles -nodefaultlibs -nostdlib
|
||||||
|
|
||||||
ifeq ($(TLB),yes)
|
ifeq ($(TLB),yes)
|
||||||
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
CFLAGS+=-DSYS_IO_BASE=0xAC000000 -DSDRAM_BASE=0x80000000 -DFLASH_BASE_IO=0xA4000000 -DFLASH_BASE_MEM=0x88000000
|
||||||
@@ -38,8 +38,11 @@ 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 libsys.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 gdb_stub.o)
|
||||||
OBJS-denano=$(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 cop0.o libsys.o srec.o board.o uart.o gdb_stub.o)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/cop0.o : ../libsys/cop0.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(BUILD_DIR)/uart.o : ../libsys/uart.c
|
$(BUILD_DIR)/uart.o : ../libsys/uart.c
|
||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|||||||
+2
-136
@@ -1,5 +1,6 @@
|
|||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include "libsys.h"
|
#include "libsys.h"
|
||||||
|
#include "srec.h"
|
||||||
|
|
||||||
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
|
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
|
||||||
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
|
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
|
||||||
@@ -16,112 +17,6 @@ typedef struct _sflash_img_hdr_t
|
|||||||
|
|
||||||
} flash_img_hdr_t;
|
} flash_img_hdr_t;
|
||||||
|
|
||||||
typedef struct _ssrec_t
|
|
||||||
{
|
|
||||||
uint32_t addr;
|
|
||||||
uint32_t size;
|
|
||||||
uint32_t type;
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
} srec_t;
|
|
||||||
|
|
||||||
enum srec_type
|
|
||||||
{
|
|
||||||
srec_err, srec_sob, srec_data, srec_rec, srec_eob
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t h2i(uint8_t *c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
uint8_t t, b = 0;
|
|
||||||
|
|
||||||
for (i=0; i < 2; i++)
|
|
||||||
{
|
|
||||||
t = c[i];
|
|
||||||
if (t >= 'A')
|
|
||||||
t = t - 'A' + 10;
|
|
||||||
else
|
|
||||||
t -= '0';
|
|
||||||
|
|
||||||
b = (b << 4) | t;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int decode_srec(srec_t *pRec, uint8_t *pBuf, int buflen)
|
|
||||||
{
|
|
||||||
uint8_t chksum, byte;
|
|
||||||
int alen, i;
|
|
||||||
|
|
||||||
if (!buflen)
|
|
||||||
return srec_err;
|
|
||||||
|
|
||||||
pRec->type = srec_rec;
|
|
||||||
alen = 0;
|
|
||||||
if ((pBuf[1] > '0') && (pBuf[1] < '4'))
|
|
||||||
{
|
|
||||||
alen = pBuf[1] - '0' + 1;
|
|
||||||
pRec->type = srec_data;
|
|
||||||
}
|
|
||||||
else if ((pBuf[1] >= '7') && (pBuf[1] <= '9'))
|
|
||||||
{
|
|
||||||
alen = 11 - (pBuf[1] - '0');
|
|
||||||
pRec->type = srec_eob;
|
|
||||||
}
|
|
||||||
else if (pBuf[1] == '0')
|
|
||||||
{
|
|
||||||
alen = 2;
|
|
||||||
pRec->type = srec_sob;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte = h2i(&pBuf[2]);
|
|
||||||
pRec->size = byte;
|
|
||||||
chksum = byte;
|
|
||||||
|
|
||||||
pRec->addr = 0;
|
|
||||||
for (i=0; i < alen; i++)
|
|
||||||
{
|
|
||||||
byte = h2i(&pBuf[4+2*i]);
|
|
||||||
pRec->addr = pRec->addr << 8 | byte;
|
|
||||||
chksum += byte;
|
|
||||||
}
|
|
||||||
pRec->size -= (alen+1);
|
|
||||||
|
|
||||||
pRec->data = (uint8_t*) &pBuf[4 + 2*alen];
|
|
||||||
for (i=0; i < (int)pRec->size; i++)
|
|
||||||
{
|
|
||||||
byte = h2i(&pRec->data[2*i]);
|
|
||||||
pRec->data[i] = byte;
|
|
||||||
chksum += byte;
|
|
||||||
}
|
|
||||||
chksum = ~chksum;
|
|
||||||
byte = h2i(&pRec->data[2*i]);
|
|
||||||
if (chksum != byte)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return pRec->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
int srec_getline(uint8_t *pLine)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = readchar();
|
|
||||||
|
|
||||||
} while ((c != 's') && (c != 'S'));
|
|
||||||
|
|
||||||
while(((c != 0x0D) && (c != 0x0A)))
|
|
||||||
{
|
|
||||||
pLine[i++] = c;
|
|
||||||
c = readchar();
|
|
||||||
};
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Jump_to(void *pEntry)
|
void Jump_to(void *pEntry)
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
@@ -172,32 +67,6 @@ void Exec_at(void *pEntry)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintCPUinfo(void)
|
|
||||||
{
|
|
||||||
int result, rev_id;
|
|
||||||
|
|
||||||
char *cpu_type_str[7] = {"invalid", "R2000", "R3000", "R6000", "R4000", "reserved", "R6000A"};
|
|
||||||
|
|
||||||
// Print Revision
|
|
||||||
result = CP0_PRID_read();
|
|
||||||
rev_id = (result >> 8) & 0xFF;
|
|
||||||
sputs("CPU type: ");
|
|
||||||
if ((rev_id > 0) && (rev_id < 0x07))
|
|
||||||
{
|
|
||||||
sputs(cpu_type_str[rev_id]);
|
|
||||||
sputs(" Rev.");
|
|
||||||
rev_id = result & 0xFF;
|
|
||||||
print_byte((char)rev_id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sputs("Unknown");
|
|
||||||
|
|
||||||
sputs("\n");
|
|
||||||
|
|
||||||
// Print Status register
|
|
||||||
sputs("Status : ");print_word(CP0_SR_read());sputs("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MAX_IMG_SIZE (1024*1024) // bytes
|
#define MAX_IMG_SIZE (1024*1024) // bytes
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -215,7 +84,6 @@ int main(int argc, char *argv[])
|
|||||||
volatile uint32_t *pSdram32 = (uint32_t*)SDRAM_BASE;
|
volatile uint32_t *pSdram32 = (uint32_t*)SDRAM_BASE;
|
||||||
|
|
||||||
sputs("\nMIPS bootloader\n");
|
sputs("\nMIPS bootloader\n");
|
||||||
PrintCPUinfo();
|
|
||||||
|
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
sputs("Loading image from flash at ");print_word((int)pFlashMem);sputs("\n");
|
sputs("Loading image from flash at ");print_word((int)pFlashMem);sputs("\n");
|
||||||
@@ -257,8 +125,6 @@ int main(int argc, char *argv[])
|
|||||||
Exec_at((void*)pSdram32);
|
Exec_at((void*)pSdram32);
|
||||||
|
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
sputs("\n\n");
|
|
||||||
PrintCPUinfo();
|
|
||||||
sputs("Booting from UART..");
|
sputs("Booting from UART..");
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
@@ -267,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
result = srec_getline(buf);
|
result = srec_getline(buf);
|
||||||
srec_state = decode_srec(&srec, buf, result);
|
srec_state = srec_decode(&srec, buf, result);
|
||||||
switch (srec_state)
|
switch (srec_state)
|
||||||
{
|
{
|
||||||
case srec_data:
|
case srec_data:
|
||||||
|
|||||||
@@ -1,18 +1,11 @@
|
|||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include "libsys.h"
|
#include "libsys.h"
|
||||||
|
#include "srec.h"
|
||||||
#include "../cfiflash.h"
|
#include "../cfiflash.h"
|
||||||
|
|
||||||
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
|
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
|
||||||
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
|
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
|
||||||
|
|
||||||
typedef struct _ssrec_t
|
|
||||||
{
|
|
||||||
uint32_t addr;
|
|
||||||
uint32_t size;
|
|
||||||
uint32_t type;
|
|
||||||
uint8_t *data;
|
|
||||||
|
|
||||||
} srec_t;
|
|
||||||
typedef struct _sflash_alloc_tbl_t
|
typedef struct _sflash_alloc_tbl_t
|
||||||
{
|
{
|
||||||
uint32_t images[16];
|
uint32_t images[16];
|
||||||
@@ -31,103 +24,6 @@ typedef struct _sflash_img_hdr_t
|
|||||||
|
|
||||||
} flash_img_hdr_t;
|
} flash_img_hdr_t;
|
||||||
|
|
||||||
enum srec_type
|
|
||||||
{
|
|
||||||
srec_err, srec_err_chksum, srec_sob, srec_data, srec_rec, srec_eob
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t h2i(uint8_t *c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
uint8_t t, b = 0;
|
|
||||||
|
|
||||||
for (i=0; i < 2; i++)
|
|
||||||
{
|
|
||||||
t = c[i];
|
|
||||||
if (t >= 'A')
|
|
||||||
t = t - 'A' + 10;
|
|
||||||
else
|
|
||||||
t -= '0';
|
|
||||||
|
|
||||||
b = (b << 4) | t;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int decode_srec(srec_t *pRec, uint8_t *pBuf, int buflen)
|
|
||||||
{
|
|
||||||
uint8_t chksum, byte;
|
|
||||||
int alen, i;
|
|
||||||
|
|
||||||
if (!buflen)
|
|
||||||
return srec_err;
|
|
||||||
|
|
||||||
pRec->type = srec_rec;
|
|
||||||
alen = 0;
|
|
||||||
if ((pBuf[1] > '0') && (pBuf[1] < '4'))
|
|
||||||
{
|
|
||||||
alen = pBuf[1] - '0' + 1;
|
|
||||||
pRec->type = srec_data;
|
|
||||||
}
|
|
||||||
else if ((pBuf[1] >= '7') && (pBuf[1] <= '9'))
|
|
||||||
{
|
|
||||||
alen = 11 - (pBuf[1] - '0');
|
|
||||||
pRec->type = srec_eob;
|
|
||||||
}
|
|
||||||
else if (pBuf[1] == '0')
|
|
||||||
{
|
|
||||||
alen = 2;
|
|
||||||
pRec->type = srec_sob;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte = h2i(&pBuf[2]);
|
|
||||||
pRec->size = byte;
|
|
||||||
chksum = byte;
|
|
||||||
|
|
||||||
pRec->addr = 0;
|
|
||||||
for (i=0; i < alen; i++)
|
|
||||||
{
|
|
||||||
byte = h2i(&pBuf[4+2*i]);
|
|
||||||
pRec->addr = pRec->addr << 8 | byte;
|
|
||||||
chksum += byte;
|
|
||||||
}
|
|
||||||
pRec->size -= (alen+1);
|
|
||||||
|
|
||||||
pRec->data = (uint8_t*) &pBuf[4 + 2*alen];
|
|
||||||
for (i=0; i < (int)pRec->size; i++)
|
|
||||||
{
|
|
||||||
byte = h2i(&pRec->data[2*i]);
|
|
||||||
pRec->data[i] = byte;
|
|
||||||
chksum += byte;
|
|
||||||
}
|
|
||||||
chksum = ~chksum;
|
|
||||||
byte = h2i(&pRec->data[2*i]);
|
|
||||||
if (chksum != byte)
|
|
||||||
return srec_err_chksum;
|
|
||||||
|
|
||||||
return pRec->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
int srec_getline(uint8_t *pLine)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c = readchar();
|
|
||||||
|
|
||||||
} while ((c != 's') && (c != 'S'));
|
|
||||||
|
|
||||||
while(((c != 0x0D) && (c != 0x0A)))
|
|
||||||
{
|
|
||||||
pLine[i++] = c;
|
|
||||||
c = readchar();
|
|
||||||
};
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Jump_to(void *pEntry)
|
void Jump_to(void *pEntry)
|
||||||
{
|
{
|
||||||
__asm
|
__asm
|
||||||
@@ -294,7 +190,7 @@ int main(int argc, char *argv[])
|
|||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
result = srec_getline(buf);
|
result = srec_getline(buf);
|
||||||
srec_state = decode_srec(&srec, buf, result);
|
srec_state = srec_decode(&srec, buf, result);
|
||||||
switch (srec_state)
|
switch (srec_state)
|
||||||
{
|
{
|
||||||
case srec_data:
|
case srec_data:
|
||||||
|
|||||||
+28
-118
@@ -7,9 +7,37 @@
|
|||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include "libsys.h"
|
#include "libsys.h"
|
||||||
#include "../../uart.h"
|
#include "../../uart.h"
|
||||||
|
#include "../../cop0.h"
|
||||||
|
|
||||||
extern uart_if_t uart_if[];
|
extern uart_if_t uart_if[];
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------
|
||||||
|
void PrintCPUinfo(void)
|
||||||
|
{
|
||||||
|
int result, rev_id;
|
||||||
|
|
||||||
|
const char *cpu_type_str[7] = {"invalid", "R2000", "R3000", "R6000", "R4000", "reserved", "R6000A"};
|
||||||
|
|
||||||
|
// Print Revision
|
||||||
|
result = CP0_PRID_read();
|
||||||
|
rev_id = (result >> 8) & 0xFF;
|
||||||
|
sputs("CPU type: ");
|
||||||
|
if ((rev_id > 0) && (rev_id < 0x07))
|
||||||
|
{
|
||||||
|
sputs(cpu_type_str[rev_id]);
|
||||||
|
sputs(" Rev.");
|
||||||
|
rev_id = result & 0xFF;
|
||||||
|
print_byte((char)rev_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sputs("Unknown");
|
||||||
|
|
||||||
|
sputs("\n");
|
||||||
|
|
||||||
|
// Print Status register
|
||||||
|
sputs("Status : ");print_word(CP0_SR_read());sputs("\n");
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
void _exit(int reason)
|
void _exit(int reason)
|
||||||
{
|
{
|
||||||
@@ -18,124 +46,6 @@ void _exit(int reason)
|
|||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MIPS specific
|
|
||||||
uint32_t CP0_SR_read(void)
|
|
||||||
{
|
|
||||||
uint32_t result;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
(
|
|
||||||
"mfc0 %[val], $12\n"
|
|
||||||
: [val] "=r" (result)
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CP0_SR_write(uint32_t val)
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
(
|
|
||||||
"mtc0 %[val], $12\n"
|
|
||||||
: /* no output */
|
|
||||||
: [val] "r" (val)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t CP0_CR_read(void)
|
|
||||||
{
|
|
||||||
uint32_t result;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
(
|
|
||||||
"mfc0 %[val], $13\n"
|
|
||||||
: [val] "=r" (result)
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CP0_CR_write(uint32_t val)
|
|
||||||
{
|
|
||||||
__asm
|
|
||||||
(
|
|
||||||
"mtc0 %[val], $13\n"
|
|
||||||
:
|
|
||||||
: [val] "r" (val)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t CP0_PRID_read(void)
|
|
||||||
{
|
|
||||||
uint32_t result;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
(
|
|
||||||
"mfc0 %[val], $15\n"
|
|
||||||
: [val] "=r" (result)
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CP0_TR_write_ptr(uint32_t* pPtr)
|
|
||||||
{
|
|
||||||
__asm__
|
|
||||||
(
|
|
||||||
"swc0 $31, 0(%[pPtr])\n"
|
|
||||||
:
|
|
||||||
: [pPtr] "r" (pPtr)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CP0_TR_read_ptr(uint32_t* pPtr)
|
|
||||||
{
|
|
||||||
__asm__
|
|
||||||
(
|
|
||||||
"lwc0 $31, 0(%[pPtr])\n"
|
|
||||||
:
|
|
||||||
: [pPtr] "r" (pPtr)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICACHE_invalidate_all(void)
|
|
||||||
{
|
|
||||||
__asm__
|
|
||||||
(
|
|
||||||
"cop0 32\n"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICACHE_invalidate_at(uint32_t* pPtr)
|
|
||||||
{
|
|
||||||
__asm__
|
|
||||||
(
|
|
||||||
"mtc0 %[pPtr], $31\n"
|
|
||||||
"cop0 33\n"
|
|
||||||
:
|
|
||||||
: [pPtr] "r" (pPtr)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DCACHE_invalidate_all(void)
|
|
||||||
{
|
|
||||||
__asm__
|
|
||||||
(
|
|
||||||
"cop0 34\n"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DCACHE_invalidate_at(uint32_t* pPtr)
|
|
||||||
{
|
|
||||||
__asm__
|
|
||||||
(
|
|
||||||
"mtc0 %[pPtr], $31\n"
|
|
||||||
"cop0 35\n"
|
|
||||||
:
|
|
||||||
: [pPtr] "r" (pPtr)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
char readchar(void)
|
char readchar(void)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-13
@@ -10,19 +10,7 @@
|
|||||||
#define IS_ERROR(e) ((e & LSYS_ERR_BASE) == LSYS_ERR_BASE)
|
#define IS_ERROR(e) ((e & LSYS_ERR_BASE) == LSYS_ERR_BASE)
|
||||||
|
|
||||||
// MIPS specific
|
// MIPS specific
|
||||||
uint32_t CP0_SR_read(void);
|
void PrintCPUinfo(void);
|
||||||
void CP0_SR_write(uint32_t val);
|
|
||||||
uint32_t CP0_CR_read(void);
|
|
||||||
void CP0_CR_write(uint32_t val);
|
|
||||||
uint32_t CP0_PRID_read(void);
|
|
||||||
uint32_t CP0_TR_read(void);
|
|
||||||
void CP0_TR_write(uint32_t val);
|
|
||||||
void CP0_TR_write_ptr(uint32_t* pPtr);
|
|
||||||
void CP0_TR_read_ptr(uint32_t* pPtr);
|
|
||||||
void ICACHE_invalidate_all(void);
|
|
||||||
void ICACHE_invalidate_at(uint32_t* pPtr);
|
|
||||||
void DCACHE_invalidate_all(void);
|
|
||||||
void DCACHE_invalidate_at(uint32_t* pPtr);
|
|
||||||
|
|
||||||
// General
|
// General
|
||||||
char readchar(void);
|
char readchar(void);
|
||||||
|
|||||||
+29
-8
@@ -111,6 +111,27 @@ void flush_i_cache()
|
|||||||
ICACHE_invalidate_all();
|
ICACHE_invalidate_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dbg_strcpy(char *pDst, const char *pSrc)
|
||||||
|
{
|
||||||
|
while(*pSrc)
|
||||||
|
{
|
||||||
|
*(pDst++) = *(pSrc++);
|
||||||
|
}
|
||||||
|
*pDst = *pSrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* dbg_memset(void *pBuffer, int value, size_t size)
|
||||||
|
{
|
||||||
|
char *pData = (char*)pBuffer;
|
||||||
|
|
||||||
|
while(size)
|
||||||
|
{
|
||||||
|
*(pData++) = (char)value;
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
return (void*)pData;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
|
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
|
||||||
/* at least NUMREGBYTES*2 are needed for register packets */
|
/* at least NUMREGBYTES*2 are needed for register packets */
|
||||||
@@ -493,10 +514,10 @@ handle_exception (unsigned long *registers)
|
|||||||
ptr = mem2hex((char *)®isters[CR], ptr, 4, 0);
|
ptr = mem2hex((char *)®isters[CR], ptr, 4, 0);
|
||||||
ptr = mem2hex((char *)®isters[PC], ptr, 4, 0);
|
ptr = mem2hex((char *)®isters[PC], ptr, 4, 0);
|
||||||
/* Floating point F00 .. F31*/
|
/* Floating point F00 .. F31*/
|
||||||
memset(ptr, '0', 8 * 32);
|
dbg_memset(ptr, '0', 8 * 32);
|
||||||
ptr += 8*32;
|
ptr += 8*32;
|
||||||
/* FCSR, FIR, RESTART*/
|
/* FCSR, FIR, RESTART*/
|
||||||
memset(ptr, '0', 8 * 3);
|
dbg_memset(ptr, '0', 8 * 3);
|
||||||
ptr += 8*3;
|
ptr += 8*3;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
}
|
}
|
||||||
@@ -525,7 +546,7 @@ handle_exception (unsigned long *registers)
|
|||||||
ptr += 4 * 2;
|
ptr += 4 * 2;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
strcpy(remcomOutBuffer,"OK");
|
dbg_strcpy(remcomOutBuffer,"OK");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -539,11 +560,11 @@ handle_exception (unsigned long *registers)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strcpy (remcomOutBuffer, "E03");
|
dbg_strcpy (remcomOutBuffer, "E03");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(remcomOutBuffer,"E01");
|
dbg_strcpy(remcomOutBuffer,"E01");
|
||||||
}
|
}
|
||||||
sputs("m:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
|
sputs("m:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
|
||||||
break;
|
break;
|
||||||
@@ -555,16 +576,16 @@ handle_exception (unsigned long *registers)
|
|||||||
{
|
{
|
||||||
if (hex2mem(ptr, (char *)addr, length, 1))
|
if (hex2mem(ptr, (char *)addr, length, 1))
|
||||||
{
|
{
|
||||||
strcpy(remcomOutBuffer, "OK");
|
dbg_strcpy(remcomOutBuffer, "OK");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(remcomOutBuffer, "E03");
|
dbg_strcpy(remcomOutBuffer, "E03");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(remcomOutBuffer, "E02");
|
dbg_strcpy(remcomOutBuffer, "E02");
|
||||||
}
|
}
|
||||||
sputs("M:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
|
sputs("M:"); print_word(addr); sputs(",");print_word(length); sputs("\n");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user