/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Context switch support for Hexagon3*4* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.5*/67#include <asm/asm-offsets.h>89.text1011/*12* The register used as a fast-path thread information pointer13* is determined as a kernel configuration option. If it happens14* to be a callee-save register, we're going to be saving and15* restoring it twice here.16*17* This code anticipates a revised ABI where R20-23 are added18* to the set of callee-save registers, but this should be19* backward compatible to legacy tools.20*/212223/*24* void switch_to(struct task_struct *prev,25* struct task_struct *next, struct task_struct *last);26*/27.p2align 228.globl __switch_to29.type __switch_to, @function3031/*32* When we exit the wormhole, we need to store the previous task33* in the new R0's pointer. Technically it should be R2, but they should34* be the same; seems like a legacy thing. In short, don't butcher35* R0, let it go back out unmolested.36*/3738__switch_to:39/*40* Push callee-saves onto "prev" stack.41* Here, we're sneaky because the LR and FP42* storage of the thread_stack structure43* is automagically allocated by allocframe,44* so we pass struct size less 8.45*/46allocframe(#(_SWITCH_STACK_SIZE - 8));47memd(R29+#(_SWITCH_R2726))=R27:26;48memd(R29+#(_SWITCH_R2524))=R25:24;49memd(R29+#(_SWITCH_R2322))=R23:22;50memd(R29+#(_SWITCH_R2120))=R21:20;51memd(R29+#(_SWITCH_R1918))=R19:18;52memd(R29+#(_SWITCH_R1716))=R17:16;53/* Stash thread_info pointer in task_struct */54memw(R0+#_TASK_THREAD_INFO) = THREADINFO_REG;55memw(R0 +#(_TASK_STRUCT_THREAD + _THREAD_STRUCT_SWITCH_SP)) = R29;56/* Switch to "next" stack and restore callee saves from there */57R29 = memw(R1 + #(_TASK_STRUCT_THREAD + _THREAD_STRUCT_SWITCH_SP));58{59R27:26 = memd(R29+#(_SWITCH_R2726));60R25:24 = memd(R29+#(_SWITCH_R2524));61}62{63R23:22 = memd(R29+#(_SWITCH_R2322));64R21:20 = memd(R29+#(_SWITCH_R2120));65}66{67R19:18 = memd(R29+#(_SWITCH_R1918));68R17:16 = memd(R29+#(_SWITCH_R1716));69}70{71/* THREADINFO_REG is currently one of the callee-saved regs72* above, and so be sure to re-load it last.73*/74THREADINFO_REG = memw(R1 + #_TASK_THREAD_INFO);75R31:30 = memd(R29+#_SWITCH_FP);76}77{78R29 = add(R29,#_SWITCH_STACK_SIZE);79jumpr R31;80}81.size __switch_to, .-__switch_to828384