Linux Audio

Check our new training course

Loading...
v6.13.7
 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; IN
15;  - r0: prev task (also current)
16;  - r1: next task
17; OUT
18;  - r0: prev task (so r0 not touched)
19
20	.section .sched.text,"ax",@progbits
21ENTRY_CFI(__switch_to)
22
23	/* save kernel stack frame regs of @prev task */
24	push	blink
25	CFI_DEF_CFA_OFFSET 4
26	CFI_OFFSET r31, -4
27
28	push	fp
29	CFI_DEF_CFA_OFFSET 8
30	CFI_OFFSET r27, -8
 
 
 
 
 
 
 
31
32	mov	fp, sp
33	CFI_DEF_CFA_REGISTER r27
 
 
 
 
 
 
 
 
 
 
 
 
34
35	/* kernel mode callee regs of @prev */
36	SAVE_CALLEE_SAVED_KERNEL
37
38	/*
39	 * save final SP to @prev->thread_info.ksp
40	 * @prev is "current" so thread_info derived from SP
41	 */
42	GET_CURR_THR_INFO_FROM_SP  r10
43	st	sp,  [r10, THREAD_INFO_KSP]
44
45	/* update @next in _current_task[] and GP register caching it */
46	SET_CURR_TASK_ON_CPU  r1, r10
47
48	/* load SP from @next->thread_info.ksp */
49	ld	r10, [r1, TASK_THREAD_INFO]
50	ld	sp,  [r10, THREAD_INFO_KSP]
51
52	/* restore callee regs, stack frame regs of @next */
53	RESTORE_CALLEE_SAVED_KERNEL
 
 
 
54
55	pop	fp
56	CFI_RESTORE r27
57	CFI_DEF_CFA r28, 4
58
59	pop	blink
60	CFI_RESTORE r31
61	CFI_DEF_CFA_OFFSET 0
62
63	j      [blink]
64END_CFI(__switch_to)
v3.15
 
 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 <asm/entry.h>       /* For the SAVE_* macros */
14#include <asm/asm-offsets.h>
15#include <asm/linkage.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
27	/* Save regs on kernel mode stack of task */
28	st.a    blink, [sp, -4]
29	st.a    fp, [sp, -4]
30	SAVE_CALLEE_SAVED_KERNEL
31
32	/* Save the now KSP in task->thread.ksp */
33#if KSP_WORD_OFF  <= 255
34	st.as  sp, [r0, KSP_WORD_OFF]
35#else
36	/* Workaround for NR_CPUS=4k as ST.as can only take s9 offset */
37	add2	r24, r0, KSP_WORD_OFF
38	st	sp, [r24]
39#endif
40	/*
41	* Return last task in r0 (return reg)
42	* On ARC, Return reg = First Arg reg = r0.
43	* Since we already have last task in r0,
44	* don't need to do anything special to return it
45	*/
46
47	/* hardware memory barrier */
48	sync
49
50	/*
51	 * switch to new task, contained in r1
52	 * Temp reg r3 is required to get the ptr to store val
53	 */
54	SET_CURR_TASK_ON_CPU  r1, r3
 
55
56	/* reload SP with kernel mode stack pointer in task->thread.ksp */
57	ld.as  sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
58
59	/* restore the registers */
 
 
 
 
60	RESTORE_CALLEE_SAVED_KERNEL
61	ld.ab   fp, [sp, 4]
62	ld.ab   blink, [sp, 4]
63	j       [blink]
64
65END(__switch_to)