- Cleanedup toolchain
Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@381 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
CFLAGS=-msoft-float -O2 -march=r3000 -I.
|
CFLAGS=-msoft-float -O2 -march=r3000 -I. -Wl,-M
|
||||||
LFLAGS=-M -T link.ld
|
LIBS=-lc -lm
|
||||||
LIB_DIRS=-L . -L $(MIPS_TOOLS_PREFIX)/mipsel-elf/lib -L $(MIPS_TOOLS_PREFIX)/lib/gcc/mipsel-elf/$(MIPS_GCC_VER)
|
|
||||||
LIBS=-lc -lm -lgcc
|
|
||||||
|
|
||||||
AS=mipsel-elf-as
|
AS=mipsel-elf-as
|
||||||
AR=mipsel-elf-ar
|
AR=mipsel-elf-ar
|
||||||
@@ -15,122 +14,107 @@ PROG = hello testbench test_irq dhry queens stanford paranoia rmd160_test Bessel
|
|||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
|
|
||||||
libsys: startup.S init.S kernel.S libsys.c xcpt.c irq.c
|
libsys: startup.S kernel.S libsys.c xcpt.c irq.c
|
||||||
$(CC) $(CFLAGS) -G 0 -c startup.S -o startup.o
|
$(CC) $(CFLAGS) -G 0 -c startup.S -o startup.o
|
||||||
$(CC) $(CFLAGS) -G 0 -c kernel.S -o kernel.o
|
$(CC) $(CFLAGS) -G 0 -c kernel.S -o kernel.o
|
||||||
$(CC) $(CFLAGS) -G 0 -c init.S -o init.o
|
|
||||||
$(CC) $(CFLAGS) -G 0 -c libsys.c -o libsys.o
|
$(CC) $(CFLAGS) -G 0 -c libsys.c -o libsys.o
|
||||||
$(CC) $(CFLAGS) -G 0 -c xcpt.c -o xcpt.o
|
$(CC) $(CFLAGS) -G 0 -c xcpt.c -o xcpt.o
|
||||||
$(CC) $(CFLAGS) -G 0 -c irq.c -o irq.o
|
$(CC) $(CFLAGS) -G 0 -c irq.c -o irq.o
|
||||||
$(AR) -r libsys.a init.o libsys.o xcpt.o irq.o
|
$(AR) -r libsys.a libsys.o xcpt.o irq.o
|
||||||
|
|
||||||
hello: hello.c
|
hello: hello.c
|
||||||
$(CC) $(CFLAGS) -c hello.c
|
$(CC) $(CFLAGS) -o $@.elf -Os -g hello.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) hello.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
testbench: testbench.c
|
testbench: testbench.c
|
||||||
$(CC) $(CFLAGS) -c testbench.c paranoia.c -DNOSIGNAL -DBATCHMODE -DNOMAIN
|
$(CC) $(CFLAGS) -o $@.elf -DNOSIGNAL -DBATCHMODE -DNOMAIN -Os -g testbench.c paranoia.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) paranoia.o testbench.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
test_irq: test_irq.c
|
test_irq: test_irq.c
|
||||||
$(CC) $(CFLAGS) -c test_irq.c
|
$(CC) $(CFLAGS) -o $@.elf test_irq.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) test_irq.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
dhry: dhry_1.c dhry_2.c dhry.h
|
dhry: dhry_1.c dhry_2.c dhry.h
|
||||||
$(CC) $(CFLAGS) -DHZ=1000 -c dhry_1.c dhry_2.c
|
$(CC) $(CFLAGS) -o $@.elf -DHZ=1000 dhry_1.c dhry_2.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) dhry_1.o dhry_2.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
queens: queens.c
|
queens: queens.c
|
||||||
$(CC) $(CFLAGS) -DUNIX_Old -DHZ=1000 -c queens.c
|
$(CC) $(CFLAGS) -o $@.elf -DUNIX_Old -DHZ=1000 queens.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) queens.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
stanford: stanford.c
|
stanford: stanford.c
|
||||||
$(CC) $(CFLAGS) -DHZ=1000 -c stanford.c
|
$(CC) $(CFLAGS) -o $@.elf -DHZ=1000 stanford.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) stanford.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
paranoia: paranoia.c
|
paranoia: paranoia.c
|
||||||
$(CC) $(CFLAGS) -DNOSIGNAL -DBATCHMODE -g -c paranoia.c
|
$(CC) $(CFLAGS) -o $@.elf -DNOSIGNAL -DBATCHMODE -g paranoia.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) paranoia.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
rmd160_test: rmd160_test.c rmd160.c rmd160.h
|
rmd160_test: rmd160_test.c rmd160.c rmd160.h
|
||||||
$(CC) $(CFLAGS) -DNOSIGNAL -DBATCHMODE -g -c rmd160.c rmd160_test.c
|
$(CC) $(CFLAGS) -o $@.elf -DNOSIGNAL -DBATCHMODE -g rmd160.c rmd160_test.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) rmd160.o rmd160_test.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
Bessel: Bessel.c
|
Bessel: Bessel.c
|
||||||
$(CC) $(CFLAGS) -g -c Bessel.c
|
$(CC) $(CFLAGS) -o $@.elf -g Bessel.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) Bessel.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
whet: whet.c
|
whet: whet.c
|
||||||
$(CC) $(CFLAGS) -c whet.c
|
$(CC) $(CFLAGS) -o $@.elf whet.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) whet.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
phrasen: phrasen.c
|
phrasen: phrasen.c
|
||||||
$(CC) $(CFLAGS) -g -c phrasen.c
|
$(CC) $(CFLAGS) -o $@.elf -g phrasen.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) phrasen.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
dttl: dttl.c random.c
|
dttl: dttl.c random.c
|
||||||
$(CC) $(CFLAGS) -g -c dttl.c random.c
|
$(CC) $(CFLAGS) -o $@.elf -g dttl.c random.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) random.o dttl.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
richards_benchmark: richards_benchmark.c
|
richards_benchmark: richards_benchmark.c
|
||||||
$(CC) $(CFLAGS) -c richards_benchmark.c
|
$(CC) $(CFLAGS) -o $@.elf richards_benchmark.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) richards_benchmark.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
$(FLASHGEN) $@.bin
|
$(FLASHGEN) $@.bin
|
||||||
|
|
||||||
test_exception: test_exception.c
|
test_exception: test_exception.c
|
||||||
$(CC) $(CFLAGS) -O1 -c test_exception.c
|
$(CC) $(CFLAGS) -o $@.elf -O1 test_exception.c $(LIBS) >$@.map
|
||||||
$(LD) $(LFLAGS) $(LIB_DIRS) test_exception.o -o $@.elf $(LIBS) >$@.map
|
|
||||||
$(OBJDUMP) -d $@.elf > $@.dis
|
$(OBJDUMP) -d $@.elf > $@.dis
|
||||||
$(OBJCOPY) $@.elf -O binary $@.bin
|
$(OBJCOPY) $@.elf -O binary $@.bin
|
||||||
$(OBJCOPY) -O srec $@.elf $@.srec
|
$(OBJCOPY) -O srec $@.elf $@.srec
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
ROM_WORDADDR_WIDTH=11
|
|
||||||
|
|
||||||
CFLAGS=-Os -I. -I../ -msoft-float -march=r3000
|
CFLAGS=-Os -I. -I../ -msoft-float -march=r3000
|
||||||
LFLAGS=-M -T bootloader.ld
|
LFLAGS=-M -T bootloader.ld
|
||||||
LIB_DIRS=-L $(MIPS_TOOLS_PREFIX)/mipsel-elf/lib -L $(MIPS_TOOLS_PREFIX)/lib/gcc/mipsel-elf/$(MIPS_GCC_VER)
|
LIB_DIRS=-L $(MIPS_TOOLS_PREFIX)/mipsel-elf/lib -L $(MIPS_TOOLS_PREFIX)/lib/gcc/mipsel-elf/$(MIPS_GCC_VER)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ sys_timer_sec = 0xA000000C;
|
|||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.stext ORIGIN(rom) :
|
.init ORIGIN(rom) :
|
||||||
{
|
{
|
||||||
start = ALIGN(4);
|
start = ALIGN(4);
|
||||||
entry = ALIGN(4);
|
entry = ALIGN(4);
|
||||||
|
|||||||
@@ -9,12 +9,17 @@ typedef struct _ssrec_t
|
|||||||
UINT8 *data;
|
UINT8 *data;
|
||||||
|
|
||||||
} srec_t;
|
} srec_t;
|
||||||
|
typedef struct _sflash_alloc_tbl_t
|
||||||
|
{
|
||||||
|
UINT32 images[16];
|
||||||
|
|
||||||
|
} flash_alloc_tbl_t;
|
||||||
|
|
||||||
typedef struct _sflash_img_hdr_t
|
typedef struct _sflash_img_hdr_t
|
||||||
{
|
{
|
||||||
UINT8 magic[4];
|
UINT8 magic[4];
|
||||||
UINT32 target_addr;
|
UINT32 target_base;
|
||||||
UINT32 img_offset;
|
UINT32 img_base;
|
||||||
UINT32 img_size;
|
UINT32 img_size;
|
||||||
UINT32 hdr_next;
|
UINT32 hdr_next;
|
||||||
UINT8 img_name[128];
|
UINT8 img_name[128];
|
||||||
@@ -207,7 +212,8 @@ void PrintCPUinfo(void)
|
|||||||
|
|
||||||
#define MAX_IMG_SIZE (1024*1024) // bytes
|
#define MAX_IMG_SIZE (1024*1024) // bytes
|
||||||
#define SDRAM_BASE 0x40000000
|
#define SDRAM_BASE 0x40000000
|
||||||
#define FLASH_OFFSET 0x00000000
|
#define FLASHIO_OFFSET 0x00000000
|
||||||
|
#define FLASH_BASE 0x00000000
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -222,10 +228,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
volatile UINT32 *pReg = (UINT32*)sys_led_port;
|
volatile UINT32 *pReg = (UINT32*)sys_led_port;
|
||||||
volatile UINT32 *pBtn = (UINT32*)sys_gpio0;
|
volatile UINT32 *pBtn = (UINT32*)sys_gpio0;
|
||||||
|
volatile UINT32 *pDip = (UINT32*)sys_gpio1;
|
||||||
volatile UINT8 *pMem;
|
volatile UINT8 *pMem;
|
||||||
volatile UINT32 *pROM32;
|
volatile UINT32 *pROM32;
|
||||||
volatile UINT32 *pMem32;
|
volatile UINT32 *pMem32;
|
||||||
volatile UINT32 *pFlash = (UINT32*)sys_flash_io;
|
volatile UINT32 *pFlashIO = (UINT32*)sys_flash_io;
|
||||||
volatile UINT32 *pUSB = (UINT32*)sys_usb_data;
|
volatile UINT32 *pUSB = (UINT32*)sys_usb_data;
|
||||||
|
|
||||||
volatile UINT8 *ram8 = (UINT8*)SDRAM_BASE;
|
volatile UINT8 *ram8 = (UINT8*)SDRAM_BASE;
|
||||||
@@ -237,20 +244,20 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
ram32 = (UINT32*)(SDRAM_BASE);
|
ram32 = (UINT32*)(SDRAM_BASE);
|
||||||
pFlash = (UINT32*)(sys_flash_io + FLASH_OFFSET);
|
pFlashIO = (UINT32*)(sys_flash_io + FLASHIO_OFFSET);
|
||||||
|
|
||||||
if (!*pBtn)
|
if (!*pBtn)
|
||||||
{
|
{
|
||||||
sputs("\n\n");
|
sputs("\n\n");
|
||||||
sputs("Booting from flash...");
|
sputs("Booting application from flash...");
|
||||||
|
|
||||||
pImg_hdr = (flash_img_hdr_t*)pFlash;
|
pImg_hdr = (flash_img_hdr_t*)pFlashIO;
|
||||||
ram32 = (UINT32*)pImg_hdr->target_addr;
|
ram32 = (UINT32*)pImg_hdr->target_base;
|
||||||
pFlash = (UINT32*)(sys_flash_io + pImg_hdr->img_offset);
|
pFlashIO = (UINT32*)(sys_flash_io + pImg_hdr->img_base);
|
||||||
img_size = pImg_hdr->img_size;
|
img_size = pImg_hdr->img_size;
|
||||||
|
|
||||||
for (i=0; i < img_size/4; i++)
|
for (i=0; i < img_size/4; i++)
|
||||||
ram32[i] = pFlash[i];
|
ram32[i] = pFlashIO[i];
|
||||||
|
|
||||||
sputs("done\n\n");
|
sputs("done\n\n");
|
||||||
|
|
||||||
@@ -259,6 +266,17 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
sputs("\n\n");
|
||||||
|
|
||||||
|
if (*pDip)
|
||||||
|
{
|
||||||
|
sputs("Booting stage 2 from flash.\n");
|
||||||
|
Jump_to((void*)FLASH_BASE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sputs("Reading HEX-Record from UART..");
|
||||||
|
|
||||||
if (flash_find(&flash, sys_flash_io) < 0)
|
if (flash_find(&flash, sys_flash_io) < 0)
|
||||||
{
|
{
|
||||||
sputs("Cannot find flash device. Exit now!\n\n");
|
sputs("Cannot find flash device. Exit now!\n\n");
|
||||||
@@ -269,8 +287,6 @@ int main(int argc, char *argv[])
|
|||||||
for (i=0; i < MAX_IMG_SIZE/4; i++)
|
for (i=0; i < MAX_IMG_SIZE/4; i++)
|
||||||
ram32[i] = 0;
|
ram32[i] = 0;
|
||||||
|
|
||||||
sputs("\n\n");
|
|
||||||
sputs("Booting from UART..");
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
@@ -299,13 +315,14 @@ int main(int argc, char *argv[])
|
|||||||
img_hdr.magic[1] = 'F';
|
img_hdr.magic[1] = 'F';
|
||||||
img_hdr.magic[2] = 'I';
|
img_hdr.magic[2] = 'I';
|
||||||
img_hdr.magic[3] = '1';
|
img_hdr.magic[3] = '1';
|
||||||
img_hdr.target_addr = srec.addr;
|
img_hdr.target_base = srec.addr;
|
||||||
img_hdr.img_size = haddr - srec.addr;
|
img_hdr.img_size = haddr - srec.addr;
|
||||||
img_hdr.img_offset = FLASH_OFFSET + sizeof(flash_img_hdr_t);
|
img_hdr.img_base = FLASHIO_OFFSET + sizeof(flash_img_hdr_t);
|
||||||
img_hdr.hdr_next = FLASH_OFFSET;
|
img_hdr.hdr_next = flash_get_nextblock(&flash, img_hdr.img_base + img_hdr.img_size);
|
||||||
|
sputs("Next free flash offset: ");print_word(img_hdr.hdr_next); sputs("\n");
|
||||||
|
|
||||||
sputs("Flash erase...");
|
sputs("Flash erase...");
|
||||||
result = flash_erase(&flash, FLASH_OFFSET, img_hdr.img_size + sizeof(flash_img_hdr_t));
|
result = flash_erase(&flash, FLASHIO_OFFSET, img_hdr.img_size + sizeof(flash_img_hdr_t));
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
sputs("failed!\n");
|
sputs("failed!\n");
|
||||||
@@ -314,13 +331,13 @@ int main(int argc, char *argv[])
|
|||||||
sputs("done\n");
|
sputs("done\n");
|
||||||
|
|
||||||
sputs("Flash write...");
|
sputs("Flash write...");
|
||||||
result = flash_program(&flash, FLASH_OFFSET, (UINT8*)&img_hdr, sizeof(flash_img_hdr_t));
|
result = flash_program(&flash, FLASHIO_OFFSET, (UINT8*)&img_hdr, sizeof(flash_img_hdr_t));
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
sputs("failed!\n");
|
sputs("failed!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result = flash_program(&flash, img_hdr.img_offset, (UINT8*)ram32, img_hdr.img_size);
|
result = flash_program(&flash, img_hdr.img_base, (UINT8*)ram32, img_hdr.img_size);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
sputs("failed!\n");
|
sputs("failed!\n");
|
||||||
@@ -329,7 +346,7 @@ int main(int argc, char *argv[])
|
|||||||
sputs("done\n");
|
sputs("done\n");
|
||||||
|
|
||||||
sputs("Flash verify...");
|
sputs("Flash verify...");
|
||||||
result = flash_verify(&flash, img_hdr.img_offset, (UINT8*)ram32, img_hdr.img_size);
|
result = flash_verify(&flash, img_hdr.img_base, (UINT8*)ram32, img_hdr.img_size);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
sputs("failed!\n");
|
sputs("failed!\n");
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
.file "init.S"
|
.file "init.S"
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
.section .init,"ax"
|
||||||
.align 2
|
.align 2
|
||||||
.globl _init
|
.globl _init
|
||||||
.extern end
|
.extern end
|
||||||
@@ -12,197 +13,7 @@ _init:
|
|||||||
la $26, sys_uart_baud
|
la $26, sys_uart_baud
|
||||||
addiu $27, $0, baudrate
|
addiu $27, $0, baudrate
|
||||||
sb $27, 0($26)
|
sb $27, 0($26)
|
||||||
|
|
||||||
# set stack pointer
|
|
||||||
la $sp, stack_ptr
|
|
||||||
j $jmain
|
|
||||||
|
|
||||||
# TEST
|
jr $ra
|
||||||
li $26, +5
|
|
||||||
beqz $26, _terminate
|
|
||||||
li $26, -5
|
|
||||||
beqz $26, _terminate
|
|
||||||
li $26, 0
|
|
||||||
beqz $26, $_L11
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
nop
|
|
||||||
$_L11:
|
|
||||||
li $26, +5
|
|
||||||
li $27, +6
|
|
||||||
beq $26, $27, _terminate
|
|
||||||
li $26, -5
|
|
||||||
beq $26, $27, _terminate
|
|
||||||
li $26, 0
|
|
||||||
beq $26, $27, _terminate
|
|
||||||
li $26, +6
|
|
||||||
beq $26, $27, $_L12
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
nop
|
|
||||||
$_L12:
|
|
||||||
li $26, -5
|
|
||||||
bgez $26, _terminate
|
|
||||||
li $26, +5
|
|
||||||
bgez $26, $_L13
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L13: li $26, 0
|
|
||||||
bgez $26, $_L14
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L14:
|
|
||||||
li $26, -5
|
|
||||||
bgtz $26, _terminate
|
|
||||||
li $26, 0
|
|
||||||
bgtz $26, _terminate
|
|
||||||
li $26, +5
|
|
||||||
bgtz $26, $_L15
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
|
|
||||||
$_L15:
|
|
||||||
li $26, +5
|
|
||||||
blez $26, _terminate
|
|
||||||
li $26, 0
|
|
||||||
blez $26, $_L16
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L16: li $26, -5
|
|
||||||
blez $26, $_L17
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
|
|
||||||
$_L17:
|
|
||||||
li $26, +5
|
|
||||||
bltz $26, _terminate
|
|
||||||
li $26, 0
|
|
||||||
bltz $26, _terminate
|
|
||||||
li $26, -5
|
|
||||||
bltz $26, $_L18
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L18:
|
|
||||||
li $26, +5
|
|
||||||
li $27, +6
|
|
||||||
bne $26, $27, $_L19
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L19: li $26, -5
|
|
||||||
bne $26, $27, $_L20
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L20: li $26, -6
|
|
||||||
bne $26, $27, $_L21
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L21: li $26, 0
|
|
||||||
bne $26, $27, $_L22
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L22: li $26, +6
|
|
||||||
bne $26, $27, _terminate
|
|
||||||
li $26, +5
|
|
||||||
bnez $26, $_L23
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L23: li $26, -5
|
|
||||||
bnez $26, $_L24
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
$_L24: li $26, 0
|
|
||||||
bnez $26, _terminate
|
|
||||||
|
|
||||||
$_L25:
|
|
||||||
li $27, +5
|
|
||||||
sltiu $26,$27,+6
|
|
||||||
sltiu $26,$27,-6
|
|
||||||
li $27, -5
|
|
||||||
sltiu $26,$27,+6
|
|
||||||
sltiu $26,$27,-6
|
|
||||||
li $27, +6
|
|
||||||
sltiu $26,$27,+5
|
|
||||||
sltiu $26,$27,-5
|
|
||||||
li $27, -6
|
|
||||||
sltiu $26,$27,+5
|
|
||||||
sltiu $26,$27,-5
|
|
||||||
|
|
||||||
li $27, +5
|
|
||||||
slti $26,$27,+6
|
|
||||||
slti $26,$27,-6
|
|
||||||
li $27, -5
|
|
||||||
slti $26,$27,+6
|
|
||||||
slti $26,$27,-6
|
|
||||||
li $27, +6
|
|
||||||
slti $26,$27,+5
|
|
||||||
slti $26,$27,-5
|
|
||||||
li $27, -6
|
|
||||||
slti $26,$27,+5
|
|
||||||
slti $26,$27,-5
|
|
||||||
|
|
||||||
|
|
||||||
li $26, +5
|
|
||||||
li $27, +6
|
|
||||||
sltu $26,$26,$27
|
|
||||||
li $26, +5
|
|
||||||
li $27, -6
|
|
||||||
sltu $26,$26,$27
|
|
||||||
li $26, -5
|
|
||||||
li $27, +6
|
|
||||||
sltu $26,$26,$27
|
|
||||||
li $26, -5
|
|
||||||
li $27, -6
|
|
||||||
sltu $26,$26,$27
|
|
||||||
|
|
||||||
li $26, +6
|
|
||||||
li $27, +5
|
|
||||||
sltu $26,$26,$27
|
|
||||||
li $26, +6
|
|
||||||
li $27, -5
|
|
||||||
sltu $26,$26,$27
|
|
||||||
li $26, -6
|
|
||||||
li $27, +5
|
|
||||||
sltu $26,$26,$27
|
|
||||||
li $26, -6
|
|
||||||
li $27, -5
|
|
||||||
sltu $26,$26,$27
|
|
||||||
|
|
||||||
li $26, +5
|
|
||||||
li $27, +6
|
|
||||||
slt $26,$26,$27
|
|
||||||
li $26, +5
|
|
||||||
li $27, -6
|
|
||||||
slt $26,$26,$27
|
|
||||||
li $26, -5
|
|
||||||
li $27, +6
|
|
||||||
slt $26,$26,$27
|
|
||||||
li $26, -5
|
|
||||||
li $27, -6
|
|
||||||
slt $26,$26,$27
|
|
||||||
|
|
||||||
li $26, +6
|
|
||||||
li $27, +5
|
|
||||||
slt $26,$26,$27
|
|
||||||
li $26, +6
|
|
||||||
li $27, -5
|
|
||||||
slt $26,$26,$27
|
|
||||||
li $26, -6
|
|
||||||
li $27, +5
|
|
||||||
slt $26,$26,$27
|
|
||||||
li $26, -6
|
|
||||||
li $27, -5
|
|
||||||
slt $26,$26,$27
|
|
||||||
|
|
||||||
# TEST
|
|
||||||
|
|
||||||
|
|
||||||
# jump main
|
|
||||||
$jmain: la $26, main
|
|
||||||
jalr $26
|
|
||||||
|
|
||||||
_terminate:
|
|
||||||
nop
|
|
||||||
j _terminate
|
|
||||||
nop
|
|
||||||
|
|
||||||
.set reorder
|
.set reorder
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
.file "startup.S"
|
.file "startup.S"
|
||||||
|
|
||||||
.section .stext,"ax"
|
.text
|
||||||
|
.section .init,"ax"
|
||||||
.extern _init
|
.extern _init
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
.set noreorder
|
.set noreorder
|
||||||
|
|
||||||
|
# set stack pointer
|
||||||
|
la $sp, stack_ptr
|
||||||
|
|
||||||
# Set Kernel mode
|
# Set Kernel mode
|
||||||
li $26, 0x1040000C
|
li $26, 0x1040000C
|
||||||
mtc0 $26, $12
|
mtc0 $26, $12
|
||||||
@@ -19,7 +23,15 @@ _start:
|
|||||||
|
|
||||||
# jump init
|
# jump init
|
||||||
la $26, _init
|
la $26, _init
|
||||||
jr $26
|
jalr $26
|
||||||
|
nop
|
||||||
|
|
||||||
|
la $26, main
|
||||||
|
jalr $26
|
||||||
|
nop
|
||||||
|
_terminate:
|
||||||
|
nop
|
||||||
|
j _terminate
|
||||||
nop
|
nop
|
||||||
|
|
||||||
.set reorder
|
.set reorder
|
||||||
|
|||||||
@@ -20,6 +20,17 @@ UINT32 cfi_get_status(flash_t *pObj)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT32 flash_get_nextblock(flash_t *pObj, UINT32 offset)
|
||||||
|
{
|
||||||
|
UINT32 blocknum;
|
||||||
|
|
||||||
|
blocknum = offset/pObj->info.blocksize;
|
||||||
|
if (offset%pObj->info.blocksize)
|
||||||
|
blocknum++;
|
||||||
|
|
||||||
|
return blocknum*pObj->info.blocksize;
|
||||||
|
}
|
||||||
|
|
||||||
void cfi_init(flash_t *pObj, UINT32 base_addr)
|
void cfi_init(flash_t *pObj, UINT32 base_addr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ UINT32 cfi_block_erase(flash_t *pObj, UINT32 word_index);
|
|||||||
UINT32 cfi_program_single(flash_t *pObj, UINT32 word_index, UINT32 word);
|
UINT32 cfi_program_single(flash_t *pObj, UINT32 word_index, UINT32 word);
|
||||||
UINT32 cfi_program_multi(flash_t *pObj, UINT32 word_index, UINT32 *pWords, UINT32 num_words);
|
UINT32 cfi_program_multi(flash_t *pObj, UINT32 word_index, UINT32 *pWords, UINT32 num_words);
|
||||||
|
|
||||||
|
UINT32 flash_get_nextblock(flash_t *pObj, UINT32 offset);
|
||||||
UINT32 flash_find(flash_t *pObj, UINT32 base_addr);
|
UINT32 flash_find(flash_t *pObj, UINT32 base_addr);
|
||||||
UINT32 flash_erase(flash_t *pObj, UINT32 offset, UINT32 size);
|
UINT32 flash_erase(flash_t *pObj, UINT32 offset, UINT32 size);
|
||||||
UINT32 flash_program(flash_t *pObj, UINT32 offset, UINT8 *pData, UINT32 size);
|
UINT32 flash_program(flash_t *pObj, UINT32 offset, UINT8 *pData, UINT32 size);
|
||||||
|
|||||||
@@ -397,18 +397,26 @@ void print_word(int word)
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
void PrintBuffer8(UINT8 *pBuf, int nbpr, int len)
|
void PrintBuffer8(UINT8 *pBuf, int nbpr, int len)
|
||||||
{
|
{
|
||||||
int i, j, cnt_hex, cnt_asc;
|
memdump(pBuf, 1, nbpr, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len)
|
||||||
|
{
|
||||||
|
int i, j, cnt_hex, cnt_asc, base;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
i = j = 0;
|
i = j = 0;
|
||||||
cnt_hex = len;
|
cnt_hex = len;
|
||||||
cnt_asc = len;
|
cnt_asc = len;
|
||||||
|
base = 0;
|
||||||
|
if (!print_offset_only)
|
||||||
|
base = (int)pBuf;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
print_word(i);
|
print_word(base + i);
|
||||||
sputs(": ");
|
sputs(": ");
|
||||||
for (j=0; j < nbpr; j++)
|
for (j=0; j < num_bytes_per_row; j++)
|
||||||
{
|
{
|
||||||
if (cnt_hex)
|
if (cnt_hex)
|
||||||
{
|
{
|
||||||
@@ -425,7 +433,7 @@ void PrintBuffer8(UINT8 *pBuf, int nbpr, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sputs(" ");
|
sputs(" ");
|
||||||
for (j=0; j < nbpr; j++)
|
for (j=0; j < num_bytes_per_row; j++)
|
||||||
{
|
{
|
||||||
if (cnt_asc)
|
if (cnt_asc)
|
||||||
{
|
{
|
||||||
@@ -443,7 +451,7 @@ void PrintBuffer8(UINT8 *pBuf, int nbpr, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sputs("\n");
|
sputs("\n");
|
||||||
i += nbpr;
|
i += num_bytes_per_row;
|
||||||
|
|
||||||
} while (cnt_hex);
|
} while (cnt_hex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ void _exit (int exitcode);
|
|||||||
void sleep(unsigned ms);
|
void sleep(unsigned ms);
|
||||||
|
|
||||||
void PrintBuffer8(UINT8 *pBuf, int nbpr, int len);
|
void PrintBuffer8(UINT8 *pBuf, int nbpr, int len);
|
||||||
|
void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len);
|
||||||
|
|
||||||
#endif // LIBSYS_H
|
#endif // LIBSYS_H
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
|
|||||||
"elf32-littlemips")
|
"elf32-littlemips")
|
||||||
OUTPUT_ARCH(mips)
|
OUTPUT_ARCH(mips)
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
SEARCH_DIR(".");
|
||||||
SEARCH_DIR("/usr/local/mipsel-elf/lib");
|
SEARCH_DIR("/usr/local/mipsel-elf/lib");
|
||||||
|
SEARCH_DIR("/usr/local/lib/gcc/mipsel-elf/4.3.3");
|
||||||
|
|
||||||
stack_ptr = 0x7FFFEFF0;
|
stack_ptr = 0x7FFFEFF0;
|
||||||
baudrate = 0x0D;
|
baudrate = 0x0D;
|
||||||
@@ -15,78 +17,24 @@ sys_timer_usec = 0xA000008;
|
|||||||
sys_timer_sec = 0xA000000C;
|
sys_timer_sec = 0xA000000C;
|
||||||
|
|
||||||
STARTUP(startup.o)
|
STARTUP(startup.o)
|
||||||
INPUT(kernel.o)
|
|
||||||
INPUT(libsys.a)
|
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
/* Read-only sections, merged into text segment: */
|
/* Read-only sections, merged into text segment: */
|
||||||
PROVIDE (__executable_start = 0x40000000); . = 0x40000000;
|
PROVIDE (__executable_start = 0x40000000); . = 0x40000000;
|
||||||
.etext __executable_start :
|
.start __executable_start :
|
||||||
{
|
{
|
||||||
start = ALIGN(2);
|
start = ALIGN(2);
|
||||||
entry = ALIGN(2);
|
entry = ALIGN(2);
|
||||||
_entry = ALIGN(2);
|
_entry = ALIGN(2);
|
||||||
__entry = ALIGN(2);
|
__entry = ALIGN(2);
|
||||||
*(.etext)
|
*(.start)
|
||||||
}
|
}
|
||||||
|
/* Kernel text with low-level exception handler */
|
||||||
.ktext __executable_start + 0x180 :
|
.ktext __executable_start + 0x180 :
|
||||||
{
|
{
|
||||||
*(.ktext)
|
*(.ktext)
|
||||||
}
|
}
|
||||||
|
|
||||||
.interp : { *(.interp) }
|
|
||||||
.reginfo : { *(.reginfo) }
|
|
||||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
|
||||||
.dynamic : { *(.dynamic) }
|
|
||||||
.hash : { *(.hash) }
|
|
||||||
.gnu.hash : { *(.gnu.hash) }
|
|
||||||
.dynsym : { *(.dynsym) }
|
|
||||||
.dynstr : { *(.dynstr) }
|
|
||||||
.gnu.version : { *(.gnu.version) }
|
|
||||||
.gnu.version_d : { *(.gnu.version_d) }
|
|
||||||
.gnu.version_r : { *(.gnu.version_r) }
|
|
||||||
.rel.dyn :
|
|
||||||
{
|
|
||||||
*(.rel.init)
|
|
||||||
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
|
|
||||||
*(.rel.fini)
|
|
||||||
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
|
|
||||||
*(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
|
|
||||||
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
|
|
||||||
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
|
|
||||||
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
|
|
||||||
*(.rel.ctors)
|
|
||||||
*(.rel.dtors)
|
|
||||||
*(.rel.got)
|
|
||||||
*(.rel.dyn)
|
|
||||||
*(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
|
|
||||||
*(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
|
|
||||||
*(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
|
|
||||||
*(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
|
|
||||||
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
|
|
||||||
}
|
|
||||||
.rela.dyn :
|
|
||||||
{
|
|
||||||
*(.rela.init)
|
|
||||||
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
|
|
||||||
*(.rela.fini)
|
|
||||||
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
|
|
||||||
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
|
|
||||||
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
|
|
||||||
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
|
|
||||||
*(.rela.ctors)
|
|
||||||
*(.rela.dtors)
|
|
||||||
*(.rela.got)
|
|
||||||
*(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
|
|
||||||
*(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
|
|
||||||
*(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
|
|
||||||
*(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
|
|
||||||
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
|
|
||||||
}
|
|
||||||
.rel.plt : { *(.rel.plt) }
|
|
||||||
.rela.plt : { *(.rela.plt) }
|
|
||||||
.init :
|
.init :
|
||||||
{
|
{
|
||||||
KEEP (*(.init))
|
KEEP (*(.init))
|
||||||
@@ -99,7 +47,7 @@ SECTIONS
|
|||||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||||
*(.gnu.warning)
|
*(.gnu.warning)
|
||||||
*(.mips16.fn.*) *(.mips16.call.*)
|
*(.mips16.fn.*) *(.mips16.call.*)
|
||||||
}
|
} =0
|
||||||
.fini :
|
.fini :
|
||||||
{
|
{
|
||||||
KEEP (*(.fini))
|
KEEP (*(.fini))
|
||||||
|
|||||||
@@ -1,15 +1,50 @@
|
|||||||
.file "startup.S"
|
.file "startup.S"
|
||||||
|
|
||||||
.section .etext,"ax"
|
.section .rodata
|
||||||
|
.data
|
||||||
|
argv0: .asciz "\"This-MIPS-program\""
|
||||||
|
argv: .word argv0
|
||||||
|
|
||||||
|
.text
|
||||||
|
.section .start, "ax"
|
||||||
.extern _init
|
.extern _init
|
||||||
.align 2
|
.align 2
|
||||||
.globl _start
|
.globl _start
|
||||||
_start:
|
_start:
|
||||||
.set noreorder
|
.set noreorder
|
||||||
|
|
||||||
# jump init
|
# Set stack pointer
|
||||||
la $8, _init
|
la $sp, stack_ptr
|
||||||
jr $8
|
# Set global pointer
|
||||||
|
la $gp, _gp
|
||||||
|
|
||||||
|
# zero bss
|
||||||
|
la $8, __bss_start
|
||||||
|
la $9, _end
|
||||||
|
$zeroise:
|
||||||
|
sw $0, 0($8)
|
||||||
|
bne $8, $9, $zeroise
|
||||||
|
addiu $8, 4
|
||||||
|
|
||||||
|
# Call _init
|
||||||
|
la $k0, _init
|
||||||
|
jalr $k0
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
# Set environment
|
||||||
|
li $a0, 1
|
||||||
|
la $a1, argv
|
||||||
|
|
||||||
|
# Call main
|
||||||
|
la $k0, main
|
||||||
|
jalr $k0
|
||||||
|
nop
|
||||||
|
|
||||||
|
# Terminate after main returns
|
||||||
|
_terminate:
|
||||||
|
nop
|
||||||
|
la $t0, exit
|
||||||
|
jalr $t0
|
||||||
|
move $a0, $v0
|
||||||
|
|
||||||
.set reorder
|
.set reorder
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void _exc_ibe(void)
|
|||||||
__asm
|
__asm
|
||||||
(
|
(
|
||||||
".set noreorder\n"
|
".set noreorder\n"
|
||||||
" li $t1, 0xAc563440\n"
|
" li $t1, 0x10000000\n"
|
||||||
" jr $t1\n"
|
" jr $t1\n"
|
||||||
"nop\n"
|
"nop\n"
|
||||||
".set reorder\n"
|
".set reorder\n"
|
||||||
@@ -117,7 +117,7 @@ void _exc_dbe(void)
|
|||||||
__asm
|
__asm
|
||||||
(
|
(
|
||||||
".set noreorder\n"
|
".set noreorder\n"
|
||||||
" li $t1, 0xAc563440\n"
|
" li $t1, 0x10000000\n"
|
||||||
" lw $t0, 0($t1)\n"
|
" lw $t0, 0($t1)\n"
|
||||||
"nop\n"
|
"nop\n"
|
||||||
" jr $t0\n"
|
" jr $t0\n"
|
||||||
@@ -143,8 +143,6 @@ void handler1(void)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int buf[256];
|
int buf[256];
|
||||||
volatile int *pLED = (int*)sys_led_port;
|
|
||||||
volatile int *pFlash = (int*)sys_flash_io;
|
|
||||||
int i, sel;
|
int i, sel;
|
||||||
|
|
||||||
interrupt_register(0, handler0);
|
interrupt_register(0, handler0);
|
||||||
@@ -152,9 +150,6 @@ int main(void)
|
|||||||
interrupt_register(1, handler1);
|
interrupt_register(1, handler1);
|
||||||
interrupt_enable(1);
|
interrupt_enable(1);
|
||||||
|
|
||||||
for (i=0; i < 8192; i++)
|
|
||||||
*pLED = *pFlash;
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
printf("Welche exception möchten Sie testen?\n");
|
printf("Welche exception möchten Sie testen?\n");
|
||||||
|
|||||||
@@ -304,11 +304,11 @@ int pi_calc()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_SIZE (128*1024) // Bytes
|
#define TEST_SIZE (16*1024*1024) // Bytes
|
||||||
#define SMALL_TEST_SIZE (8192) // Bytes
|
#define SMALL_TEST_SIZE (8192) // Bytes
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
int result, i, j, cnt;
|
int result, i, j, cnt, size;
|
||||||
volatile UINT32 *pUART_baud = (UINT32*)sys_uart_baud;
|
volatile UINT32 *pUART_baud = (UINT32*)sys_uart_baud;
|
||||||
volatile UINT32 *pReg = (UINT32*)sys_led_port;
|
volatile UINT32 *pReg = (UINT32*)sys_led_port;
|
||||||
volatile UINT32 *pReg_usec = (UINT32*)sys_timer_usec;
|
volatile UINT32 *pReg_usec = (UINT32*)sys_timer_usec;
|
||||||
@@ -365,6 +365,9 @@ int main (void)
|
|||||||
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1000*(end-start)));
|
printf("passed (%.2f MByte/s)\n", (double)TEST_SIZE/(1000*(end-start)));
|
||||||
*/
|
*/
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
|
printf("Dump Flash\n");
|
||||||
|
PrintBuffer8((UINT8*)0, 16, 256);
|
||||||
|
|
||||||
// Memtest BEGIN
|
// Memtest BEGIN
|
||||||
printf("SDRAM Memory Test\n");
|
printf("SDRAM Memory Test\n");
|
||||||
printf("Test size %d kByte\n\n", TEST_SIZE/1024);
|
printf("Test size %d kByte\n\n", TEST_SIZE/1024);
|
||||||
@@ -523,6 +526,37 @@ int main (void)
|
|||||||
free(pSrc32);
|
free(pSrc32);
|
||||||
free(pDst32);
|
free(pDst32);
|
||||||
|
|
||||||
|
printf("Boot code read \n");
|
||||||
|
size = 0x2000;
|
||||||
|
pSrc32 = (UINT32*)0xBFC00000;
|
||||||
|
pDst32 = (UINT32*)calloc(size,sizeof(UINT32));
|
||||||
|
printf("Copying %d kBytes...", size/1024);
|
||||||
|
start = clock();
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
memcpy(pDst32, pSrc32, size);
|
||||||
|
end = clock();
|
||||||
|
printf("done (%.2f MByte/s)\n", (double)10*size/(1000*(end-start)));
|
||||||
|
memdump((UINT8*)pSrc32, 0, 16, size);
|
||||||
|
printf("Verify Boot code...");
|
||||||
|
for (i=size/4-1; i >= 0; i--)
|
||||||
|
if (pDst32[i] != pSrc32[i])
|
||||||
|
break;
|
||||||
|
i++;
|
||||||
|
if (i)
|
||||||
|
printf("failed\r\n");
|
||||||
|
else
|
||||||
|
printf("passed\r\n");
|
||||||
|
|
||||||
|
free(pDst32);
|
||||||
|
|
||||||
// Memtest END
|
// Memtest END
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
sputs("\r\n");
|
sputs("\r\n");
|
||||||
|
|||||||
@@ -113,8 +113,6 @@ int _xcpt_deliver(struct xcptcontext * _xcp)
|
|||||||
sputs("Unhandled exception <");
|
sputs("Unhandled exception <");
|
||||||
sputs(_xcpt_code_str[exc_code]);
|
sputs(_xcpt_code_str[exc_code]);
|
||||||
sputs("> at PC : ");
|
sputs("> at PC : ");
|
||||||
print_word(_xcp->epc);
|
|
||||||
sputs("\n");
|
|
||||||
|
|
||||||
if (_xcp->cr & 0x80000000)
|
if (_xcp->cr & 0x80000000)
|
||||||
{
|
{
|
||||||
@@ -124,6 +122,8 @@ int _xcpt_deliver(struct xcptcontext * _xcp)
|
|||||||
{
|
{
|
||||||
pInstr = (int*)(_xcp->epc);
|
pInstr = (int*)(_xcp->epc);
|
||||||
}
|
}
|
||||||
|
print_word((int)pInstr);
|
||||||
|
sputs("\n");
|
||||||
|
|
||||||
sputs("Instruction at exception address : ");
|
sputs("Instruction at exception address : ");
|
||||||
print_word(*pInstr);
|
print_word(*pInstr);
|
||||||
|
|||||||
Reference in New Issue
Block a user