1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #pragma once
11 
12 inline void
switch_stack(unsigned long stack,void (* func)())13 switch_stack(unsigned long stack, void (*func)())
14 {
15   register unsigned long r0 asm("r0") = 0;
16   asm volatile ( "mov sp, %[stack]   \n\t"
17                  "mov pc, %[func]    \n\t"
18 		 : : [stack] "r" (stack), [func] "r" (func), "r" (r0)
19 		 : "memory", "cc");
20 }
21 
22