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;################### Low Level Context Switch ########################## 18 19 .section .sched.text,"ax",@progbits 20 .align 4 21 .global __switch_to 22 .type __switch_to, @function 23__switch_to: 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 st.as sp, [r0, (TASK_THREAD + THREAD_KSP)/4] 32 33 /* 34 * Return last task in r0 (return reg) 35 * On ARC, Return reg = First Arg reg = r0. 36 * Since we already have last task in r0, 37 * don't need to do anything special to return it 38 */ 39 40 /* hardware memory barrier */ 41 sync 42 43 /* 44 * switch to new task, contained in r1 45 * Temp reg r3 is required to get the ptr to store val 46 */ 47 SET_CURR_TASK_ON_CPU r1, r3 48 49 /* reload SP with kernel mode stack pointer in task->thread.ksp */ 50 ld.as sp, [r1, (TASK_THREAD + THREAD_KSP)/4] 51 52 /* restore the registers */ 53 RESTORE_CALLEE_SAVED_KERNEL 54 ld.ab fp, [sp, 4] 55 ld.ab blink, [sp, 4] 56 j [blink] 57 58ARC_EXIT __switch_to 59