From 608f796648e8de74f9aac3e60db3f7d87e69e9f4 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 28 Jan 2011 03:58:51 +0100 Subject: Work on the MPU port. The exception VTOR redirection doesn't work as expected. --- os/src/init.c | 37 +++++++++++++------------------------ os/src/osdebug.c | 10 +++------- os/src/sbrk.c | 5 +++-- 3 files changed, 19 insertions(+), 33 deletions(-) (limited to 'os/src') diff --git a/os/src/init.c b/os/src/init.c index 4febb10..bb3a6fb 100644 --- a/os/src/init.c +++ b/os/src/init.c @@ -1,40 +1,29 @@ #include #include -extern void __libc_init_array() __attribute__((weak)); -extern void __libc_fini_array() __attribute__((weak)); -extern void __main() __attribute__ ((weak)); +extern void __libc_init_array(); +extern void __libc_fini_array(); +extern void __main(); extern int main(int, char **, char **); -extern void BoardEarlyInit() __attribute__((weak)); -extern void BoardLateInit() __attribute__((weak)); -extern void BoardExceptionHandler(int) __attribute__((weak)); -extern void BoardShutdown() __attribute__((weak)); +extern void BoardEarlyInit(); +extern void BoardLateInit(); +extern void BoardExceptionHandler(int); +extern void BoardShutdown(); void _exit(int return_code) __attribute__((noreturn)); void _exit(int return_code) { - if (return_code && BoardExceptionHandler) + if (return_code) BoardExceptionHandler(return_code); - if (BoardShutdown) - BoardShutdown(); + BoardShutdown(); while(1); } void _start() { - if (BoardEarlyInit) - BoardEarlyInit(); + BoardEarlyInit(); BoardConsoleInit(); BoardConsolePuts("uC-sdk - booting."); - if (__libc_init_array) - __libc_init_array(); - - if (__main) - __main(); - - if (BoardLateInit) - BoardLateInit(); - - if (__libc_fini_array) - atexit(__libc_fini_array); - + __libc_init_array(); + BoardLateInit(); + atexit(__libc_fini_array); exit(main(0, NULL, NULL)); } diff --git a/os/src/osdebug.c b/os/src/osdebug.c index 6abde30..ca1f359 100644 --- a/os/src/osdebug.c +++ b/os/src/osdebug.c @@ -82,13 +82,9 @@ void osDbgPrintf(const char * str, ...) { break; case 'p': arg_p = va_arg(ap, uintptr_t); - if (arg_p) { - dbgput("0x", 2); - for (i = sizeof(arg_p) * 2 - 1; i >= 0; i--) { - dbgput(&hex_conv[(arg_p >> (i << 2)) & 15], 1); - } - } else { - dbgput("(nil)", 5); + dbgput("0x", 2); + for (i = sizeof(arg_p) * 2 - 1; i >= 0; i--) { + dbgput(&hex_conv[(arg_p >> (i << 2)) & 15], 1); } break; case 'x': diff --git a/os/src/sbrk.c b/os/src/sbrk.c index 4085970..bff44a2 100644 --- a/os/src/sbrk.c +++ b/os/src/sbrk.c @@ -11,14 +11,15 @@ // Mostly stolen from mbed-freertos extern uintptr_t __heap_start, __heap_end; -extern uintptr_t __stack_start __attribute__((weak)); +//extern uintptr_t __stack_start; /* Low-level bulk RAM allocator -- used by Newlib's Malloc */ static void *heap_end = NULL; PRIVILEGED_FUNCTION void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) { void *prev_heap_end, *next_heap_end, *ret; - void *stack_min = (void *)(__stack_start ? __stack_start : __heap_end); +// void *stack_min = (void *)(__stack_start ? __stack_start : __heap_end); + void *stack_min = (void *)__heap_end; DBGOUT("_sbrk_r(%p, %u)\r\n", ptr, incr); -- cgit v1.2.3