* Generic AVR stuff.
This commit is contained in:
parent
20fa9351f2
commit
a3fc32318e
1 changed files with 39 additions and 0 deletions
39
cpu/avr/avr.c
Normal file
39
cpu/avr/avr.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
#include "contiki-conf.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
cpu_init(void)
|
||||||
|
{
|
||||||
|
asm volatile ("clr r1"); /* No longer needed. */
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int __bss_end;
|
||||||
|
|
||||||
|
#define STACK_EXTRA 32
|
||||||
|
static char *cur_break = (char *)(&__bss_end + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate memory from the heap. Check that we don't collide with the
|
||||||
|
* stack right now (some other routine might later). A watchdog might
|
||||||
|
* be used to check if cur_break and the stack pointer meet during
|
||||||
|
* runtime.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
sbrk(int incr)
|
||||||
|
{
|
||||||
|
char *stack_pointer;
|
||||||
|
|
||||||
|
stack_pointer = (char *)SP;
|
||||||
|
stack_pointer -= STACK_EXTRA;
|
||||||
|
if(incr > (stack_pointer - cur_break))
|
||||||
|
return (void *)-1; /* ENOMEM */
|
||||||
|
|
||||||
|
void *old_break = cur_break;
|
||||||
|
cur_break += incr;
|
||||||
|
/*
|
||||||
|
* If the stack was never here then [old_break .. cur_break] should
|
||||||
|
* be filled with zeros.
|
||||||
|
*/
|
||||||
|
return old_break;
|
||||||
|
}
|
Loading…
Reference in a new issue