Add wormhole.[ch]

This commit is contained in:
László Monda
2017-05-01 17:02:18 +02:00
parent 151925337e
commit 8675effabc
5 changed files with 61 additions and 36 deletions

17
right/src/wormhole.c Normal file
View File

@@ -0,0 +1,17 @@
#include "wormhole.h"
wormhole_t *Wormhole NO_INIT_GCC;
void* getSP(void)
{
void *sp;
// __asm__ __volatile__ ("mov %0, sp" : "=r"(sp));
__asm__ __volatile__ ("mrs %0, msp" : "=r"(sp));
return sp;
}
void __attribute__ ((__section__ (".init3"), __naked__)) move_sp(void) {
void* SP = getSP();
// SP -= sizeof(wormhole_t);
Wormhole = (wormhole_t*)(SP + 1);
}