# HG changeset patch # User Jeandet Alexis # Date 2014-01-13 22:51:49 # Node ID 68078fc5f4654dff2660a81a695cef3d19f84148 # Parent 9fa0b042767202c5bed773c6f10778f5fae0413d wraped printf for simulator. diff --git a/bsp/src/simulator/SIMULATOR/bsp.c b/bsp/src/simulator/SIMULATOR/bsp.c --- a/bsp/src/simulator/SIMULATOR/bsp.c +++ b/bsp/src/simulator/SIMULATOR/bsp.c @@ -71,6 +71,8 @@ FAT32fs sdcard2FAT32part3; dikpartition sdcard2Part4; FAT32fs sdcard2FAT32part4; + + int bsp_init() { int i=0; @@ -329,4 +331,3 @@ Uint32 getpixel(SDL_Surface *surface, in - diff --git a/examples/TEST_SIMULATOR/test_SDCARD.c b/examples/TEST_SIMULATOR/test_SDCARD.c --- a/examples/TEST_SIMULATOR/test_SDCARD.c +++ b/examples/TEST_SIMULATOR/test_SDCARD.c @@ -2,6 +2,10 @@ #include #include #include +#include +#include + + void printRootClustersChain(FAT32fs* sdcard2FAT32part) { diff --git a/examples/helloWorld/main.c b/examples/helloWorld/main.c --- a/examples/helloWorld/main.c +++ b/examples/helloWorld/main.c @@ -24,8 +24,6 @@ * the project file. The value BSP contains the board name, and UCMODEL contain * the target architecture. */ -#include - int libuc_main() { diff --git a/mkspecs/common/simulator.conf b/mkspecs/common/simulator.conf --- a/mkspecs/common/simulator.conf +++ b/mkspecs/common/simulator.conf @@ -27,7 +27,7 @@ QMAKE_LINK = gcc QMAKE_LINK_SHLIB = gcc QMAKE_LINK_C = gcc QMAKE_LINK_C_SHLIB = gcc -QMAKE_LFLAGS += -g -O0 +QMAKE_LFLAGS += -g -O0 -Wl,-wrap,printf -Wl,-wrap,puts QMAKE_LFLAGS_RELEASE += QMAKE_LFLAGS_DEBUG += QMAKE_LFLAGS_APP += diff --git a/mkspecs/features/simulator/startup.c b/mkspecs/features/simulator/startup.c --- a/mkspecs/features/simulator/startup.c +++ b/mkspecs/features/simulator/startup.c @@ -1,4 +1,32 @@ +#include +#include +#include +extern streamdevice* __opnfiles__[]; + +extern int __real_printf(const char *format,...); + +int __wrap_printf(const char *format,...) +{ + char* str_buffer; + // for(int i =0;i<512;i++)str_buffer[i]='\0'; + int i; + va_list ap; + va_start(ap,format); + vasprintf(&str_buffer,format,ap); + va_end(ap); + i=strlen(str_buffer); + __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)str_buffer,1,i); +} + +extern int __real_puts(const char *s); + +int __wrap_puts(const char *s) +{ + int i; + i=strlen(s); + __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)s,1,i); +} int main(void) { diff --git a/src/simulator/CPU/startup.c b/src/simulator/CPU/startup.c --- a/src/simulator/CPU/startup.c +++ b/src/simulator/CPU/startup.c @@ -1,4 +1,32 @@ +#include +#include +#include +extern streamdevice* __opnfiles__[]; + +extern int __real_printf(const char *format,...); + +int __wrap_printf(const char *format,...) +{ + char* str_buffer; + // for(int i =0;i<512;i++)str_buffer[i]='\0'; + int i; + va_list ap; + va_start(ap,format); + vasprintf(&str_buffer,format,ap); + va_end(ap); + i=strlen(str_buffer); + __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)str_buffer,1,i); +} + +extern int __real_puts(const char *s); + +int __wrap_puts(const char *s) +{ + int i; + i=strlen(s); + __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)s,1,i); +} int main(void) {