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 <linux/linkage.h>
14 #include <asm/entry.h> /* For the SAVE_* macros */
15 #include <asm/asm-offsets.h>
17 #define KSP_WORD_OFF ((TASK_THREAD + THREAD_KSP) / 4)
19 ;################### Low Level Context Switch ##########################
21 .section .sched.text,"ax",@progbits
24 .type __switch_to, @function
28 /* Save regs on kernel mode stack of task */
31 SAVE_CALLEE_SAVED_KERNEL
33 /* Save the now KSP in task->thread.ksp */
34 #if KSP_WORD_OFF <= 255
35 st.as sp, [r0, KSP_WORD_OFF]
37 /* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
38 add2 r24, r0, KSP_WORD_OFF
42 * Return last task in r0 (return reg)
43 * On ARC, Return reg = First Arg reg = r0.
44 * Since we already have last task in r0,
45 * don't need to do anything special to return it
49 * switch to new task, contained in r1
50 * Temp reg r3 is required to get the ptr to store val
52 SET_CURR_TASK_ON_CPU r1, r3
54 /* reload SP with kernel mode stack pointer in task->thread.ksp */
55 ld.as sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
57 /* restore the registers */
58 RESTORE_CALLEE_SAVED_KERNEL