Linux Audio

Check our new training course

Linux debugging, profiling, tracing and performance analysis training

Mar 24-27, 2025, special US time zones
Register
Loading...
v5.9
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 
 
 
 
 4 *
 5 * Vineetg: Aug 2009
 6 *  -Moved core context switch macro out of entry.S into this file.
 7 *  -This is the more "natural" hand written assembler
 8 */
 9
10#include <linux/linkage.h>
11#include <asm/entry.h>       /* For the SAVE_* macros */
12#include <asm/asm-offsets.h>
13
14#define KSP_WORD_OFF 	((TASK_THREAD + THREAD_KSP) / 4)
15
16;################### Low Level Context Switch ##########################
17
18	.section .sched.text,"ax",@progbits
19	.align 4
20	.global __switch_to
21	.type   __switch_to, @function
22__switch_to:
23	CFI_STARTPROC
24
25	/* Save regs on kernel mode stack of task */
26	st.a    blink, [sp, -4]
27	st.a    fp, [sp, -4]
28	SAVE_CALLEE_SAVED_KERNEL
29
30	/* Save the now KSP in task->thread.ksp */
31#if KSP_WORD_OFF  <= 255
32	st.as  sp, [r0, KSP_WORD_OFF]
33#else
34	/* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
35	add2	r24, r0, KSP_WORD_OFF
36	st	sp, [r24]
37#endif
38	/*
39	* Return last task in r0 (return reg)
40	* On ARC, Return reg = First Arg reg = r0.
41	* Since we already have last task in r0,
42	* don't need to do anything special to return it
43	*/
44
45	/*
46	 * switch to new task, contained in r1
47	 * Temp reg r3 is required to get the ptr to store val
48	 */
49	SET_CURR_TASK_ON_CPU  r1, r3
50
51	/* reload SP with kernel mode stack pointer in task->thread.ksp */
52	ld.as  sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
53
54	/* restore the registers */
55	RESTORE_CALLEE_SAVED_KERNEL
56	ld.ab   fp, [sp, 4]
57	ld.ab   blink, [sp, 4]
58	j       [blink]
59
60END_CFI(__switch_to)
v4.17
 
 1/*
 2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 3 *
 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.
 7 *
 8 * Vineetg: Aug 2009
 9 *  -Moved core context switch macro out of entry.S into this file.
10 *  -This is the more "natural" hand written assembler
11 */
12
13#include <linux/linkage.h>
14#include <asm/entry.h>       /* For the SAVE_* macros */
15#include <asm/asm-offsets.h>
16
17#define KSP_WORD_OFF 	((TASK_THREAD + THREAD_KSP) / 4)
18
19;################### Low Level Context Switch ##########################
20
21	.section .sched.text,"ax",@progbits
22	.align 4
23	.global __switch_to
24	.type   __switch_to, @function
25__switch_to:
26	CFI_STARTPROC
27
28	/* Save regs on kernel mode stack of task */
29	st.a    blink, [sp, -4]
30	st.a    fp, [sp, -4]
31	SAVE_CALLEE_SAVED_KERNEL
32
33	/* Save the now KSP in task->thread.ksp */
34#if KSP_WORD_OFF  <= 255
35	st.as  sp, [r0, KSP_WORD_OFF]
36#else
37	/* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
38	add2	r24, r0, KSP_WORD_OFF
39	st	sp, [r24]
40#endif
41	/*
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
46	*/
47
48	/*
49	 * switch to new task, contained in r1
50	 * Temp reg r3 is required to get the ptr to store val
51	 */
52	SET_CURR_TASK_ON_CPU  r1, r3
53
54	/* reload SP with kernel mode stack pointer in task->thread.ksp */
55	ld.as  sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
56
57	/* restore the registers */
58	RESTORE_CALLEE_SAVED_KERNEL
59	ld.ab   fp, [sp, 4]
60	ld.ab   blink, [sp, 4]
61	j       [blink]
62
63END_CFI(__switch_to)