Reduced code size by removing one PT_WAIT_THREAD call site.
[contiki-2.x.git] / cpu / avr / avr.c
blobce344d68ffdcd528da953dea24ff7db6017b3701
1 #include <avr/io.h>
3 #include "contiki-conf.h"
5 void
6 cpu_init(void)
8 asm volatile ("clr r1"); /* No longer needed. */
11 extern int __bss_end;
13 #define STACK_EXTRA 32
14 static char *cur_break = (char *)(&__bss_end + 1);
17 * Allocate memory from the heap. Check that we don't collide with the
18 * stack right now (some other routine might later). A watchdog might
19 * be used to check if cur_break and the stack pointer meet during
20 * runtime.
22 void *
23 sbrk(int incr)
25 char *stack_pointer;
27 stack_pointer = (char *)SP;
28 stack_pointer -= STACK_EXTRA;
29 if(incr > (stack_pointer - cur_break))
30 return (void *)-1; /* ENOMEM */
32 void *old_break = cur_break;
33 cur_break += incr;
35 * If the stack was never here then [old_break .. cur_break] should
36 * be filled with zeros.
38 return old_break;