mirror of
https://github.com/drasko/codezero.git
synced 2026-03-03 02:53:15 +01:00
Initial commit
This commit is contained in:
28
tasks/mm0/src/stack.c
Normal file
28
tasks/mm0/src/stack.c
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#include <l4/config.h>
|
||||
#include <l4/macros.h>
|
||||
#include <l4/types.h>
|
||||
#include INC_GLUE(memlayout.h)
|
||||
#include <string.h>
|
||||
|
||||
/* The initial temporary stack used until memory is set up */
|
||||
__attribute__ ((section("init.stack"))) char stack[4096];
|
||||
extern unsigned long __stack[]; /* Linker defined */
|
||||
|
||||
/* Moves from temporary stack to where it should be in actual. */
|
||||
void move_stack()
|
||||
{
|
||||
register unsigned int sp asm("sp");
|
||||
register unsigned int fp asm("r11");
|
||||
|
||||
unsigned int stack_offset = (unsigned long)__stack - sp;
|
||||
unsigned int frame_offset = (unsigned long)__stack - fp;
|
||||
|
||||
/* Copy current stack into new stack. NOTE: This might demand-page
|
||||
* the new stack, but maybe that won't work. */
|
||||
memcpy((void *)USER_AREA_END, __stack, stack_offset);
|
||||
sp = USER_AREA_END - stack_offset;
|
||||
fp = USER_AREA_END - frame_offset;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user