1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
6 * -Moved core context switch macro out of entry.S into this file.
7 * -This is the more "natural" hand written assembler
10 #include <linux/linkage.h>
11 #include <asm/entry.h> /* For the SAVE_* macros */
12 #include <asm/asm-offsets.h>
15 ; - r0: prev task (also current)
18 ; - r0: prev task (so r0 not touched)
20 .section .sched.text,"ax",@progbits
21 ENTRY_CFI(__switch_to)
23 /* save kernel stack frame regs of @prev task */
33 CFI_DEF_CFA_REGISTER r27
35 /* kernel mode callee regs of @prev */
36 SAVE_CALLEE_SAVED_KERNEL
39 * save final SP to @prev->thread_info.ksp
40 * @prev is "current" so thread_info derived from SP
42 GET_CURR_THR_INFO_FROM_SP r10
43 st sp, [r10, THREAD_INFO_KSP]
45 /* update @next in _current_task[] and GP register caching it */
46 SET_CURR_TASK_ON_CPU r1, r10
48 /* load SP from @next->thread_info.ksp */
49 ld r10, [r1, TASK_THREAD_INFO]
50 ld sp, [r10, THREAD_INFO_KSP]
52 /* restore callee regs, stack frame regs of @next */
53 RESTORE_CALLEE_SAVED_KERNEL