2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 * -Moved core context switch macro out of entry.S into this file.
10 * -This is the more "natural" hand written assembler
13 #include <asm/entry.h> /* For the SAVE_* macros */
14 #include <asm/asm-offsets.h>
15 #include <asm/linkage.h>
17 ;################### Low Level Context Switch ##########################
19 .section .sched.text,"ax",@progbits
22 .type __switch_to, @function
25 /* Save regs on kernel mode stack of task */
28 SAVE_CALLEE_SAVED_KERNEL
30 /* Save the now KSP in task->thread.ksp */
31 st.as sp, [r0, (TASK_THREAD + THREAD_KSP)/4]
34 * Return last task in r0 (return reg)
35 * On ARC, Return reg = First Arg reg = r0.
36 * Since we already have last task in r0,
37 * don't need to do anything special to return it
40 /* hardware memory barrier */
44 * switch to new task, contained in r1
45 * Temp reg r3 is required to get the ptr to store val
47 SET_CURR_TASK_ON_CPU r1, r3
49 /* reload SP with kernel mode stack pointer in task->thread.ksp */
50 ld.as sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
52 /* restore the registers */
53 RESTORE_CALLEE_SAVED_KERNEL