From: Sebastian Date: Tue, 2 Sep 2014 12:10:04 +0000 (+0000) Subject: d3q19: remove libc, add stubs X-Git-Url: http://sraa.de/git/?a=commitdiff_plain;h=b7305039f57fd7aef71df940b1c259a054bb0a7a;p=lattice-boltzmann-epiphany.git d3q19: remove libc, add stubs Do not link against newlib anymore. Add required stubs used by the startup code. Add own (very slow!) implementations of memcpy() and memset(). This frees about 2k in SRAM bank 0. --- diff --git a/d3q19/Makefile b/d3q19/Makefile index 5674c3d..a1d1de0 100644 --- a/d3q19/Makefile +++ b/d3q19/Makefile @@ -10,7 +10,7 @@ ECHO = /bin/echo -e ECC = e-gcc EOC = e-objcopy ECFLAGS = -Os -std=c99 -falign-loops=8 -falign-functions=8 -Wall -fsingle-precision-constant -ffast-math -ELFLAGS = -T$(EPIPHANY_HOME)/bsps/current/internal.ldf -le-lib +ELFLAGS = -T$(EPIPHANY_HOME)/bsps/current/internal.ldf -nodefaultlibs -lgcc -le-lib EOFLAGS = -R .shared_dram -R .data_bank1 -R .data_bank2 -R .data_bank3 # host application @@ -19,7 +19,7 @@ HOBJS = $(HDEST)/main.o $(HDEST)/data.o # epiphany applications EAPPS = $(DEST)/main.srec -ECOMMON = $(EDEST)/d3q19.o +ECOMMON = $(EDEST)/d3q19.o $(EDEST)/hack.o # folders HSRC = hsrc diff --git a/d3q19/esrc/d3q19.c b/d3q19/esrc/d3q19.c index d50c11b..4156ad5 100644 --- a/d3q19/esrc/d3q19.c +++ b/d3q19/esrc/d3q19.c @@ -30,7 +30,7 @@ void init(block_t f) for(int q = 0; q < 19; q++) f[z][y][x][q] = 0.1 * d3q19_w[q]; -#if 1 +#if 0 /* except here */ if(core == 0) for(int q = 0; q < 19; q++) @@ -42,7 +42,7 @@ void init(block_t f) void collide(block_t f, int x, int y, int z, FLOAT omega) { -#if 0 +#if 1 /* Zou/He boundary conditions */ if(row == 0 && z == 0) { /* top */ const FLOAT Ux = 0.0; /* wall speed */ diff --git a/d3q19/esrc/hack.c b/d3q19/esrc/hack.c new file mode 100644 index 0000000..b9117ce --- /dev/null +++ b/d3q19/esrc/hack.c @@ -0,0 +1,45 @@ +/* hack to enable libc-less project */ + +#include + +/* since we need to compile with -nodefaultlibs + because of insufficient memory, we need to + implement everything ourselves */ + +/* NOTE: NEVER RETURN FROM MAIN - THERE BE DRAGONS */ + +/* points to a reentrancy structure in libc; + since we don't use the libc, point it to data memory, + it will be overwritten later */ +void* _impure_ptr = (void*)0x4000; + +void exit(int code) +{ + while(1) __asm__ volatile("idle"); +} + +/* ================================================================== */ + +void *memcpy(void *dest, const void *src, size_t n) +{ + char *s = (char*)src; + char *d = (char*)dest; + + while(n--) { + *d++ = *s++; + } + + return(dest); +} + +void *memset(void *s, int c , size_t n) +{ + char *buf = (char*)s; + + while(n--) { + *buf++ = (char)c; + } + + return(s); +} + diff --git a/d3q19/hsrc/main.c b/d3q19/hsrc/main.c index e0363b3..fb000a2 100644 --- a/d3q19/hsrc/main.c +++ b/d3q19/hsrc/main.c @@ -95,8 +95,8 @@ int main() /* write data */ //write_populations(shm.lattice, shm.iteration); - write_density(shm.lattice, shm.iteration); - //write_velocity(shm.lattice, shm.iteration); + //write_density(shm.lattice, shm.iteration); + write_velocity(shm.lattice, shm.iteration); write_timers(shm.times, shm.iteration); } /* ================================================================ */