xref: /openbmc/linux/arch/nios2/include/asm/switch_to.h (revision 2f164822)
1 /*
2  * Copyright (C) 2004 Microtronix Datacom Ltd.
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License. See the file "COPYING" in the main directory of this archive
6  * for more details.
7  */
8 #ifndef _ASM_NIOS2_SWITCH_TO_H
9 #define _ASM_NIOS2_SWITCH_TO_H
10 
11 /*
12  * switch_to(n) should switch tasks to task ptr, first checking that
13  * ptr isn't the current task, in which case it does nothing.  This
14  * also clears the TS-flag if the task we switched to has used the
15  * math co-processor latest.
16  */
17 #define switch_to(prev, next, last)			\
18 {							\
19 	void *_last;					\
20 	__asm__ __volatile__ (				\
21 		"mov	r4, %1\n"			\
22 		"mov	r5, %2\n"			\
23 		"call	resume\n"			\
24 		"mov	%0,r4\n"			\
25 		: "=r" (_last)				\
26 		: "r" (prev), "r" (next)		\
27 		: "r4", "r5", "r7", "r8", "ra");	\
28 	(last) = _last;					\
29 }
30 
31 #endif /* _ASM_NIOS2_SWITCH_TO_H */
32