summaryrefslogtreecommitdiff
path: root/os/src
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-28 03:58:51 +0100
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2011-01-28 04:02:11 +0100
commit608f796648e8de74f9aac3e60db3f7d87e69e9f4 (patch)
tree2966b76b8d12e23f99c8fbd13aeccbb4d4ef8ce8 /os/src
parent18d53779c4fef3efca606aead2da3af40ec76332 (diff)
Work on the MPU port. The exception VTOR redirection doesn't work as expected.
Diffstat (limited to 'os/src')
-rw-r--r--os/src/init.c37
-rw-r--r--os/src/osdebug.c10
-rw-r--r--os/src/sbrk.c5
3 files changed, 19 insertions, 33 deletions
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 <stdlib.h>
#include <BoardConsole.h>
-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);