David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 1 | ############################################################################### |
| 2 | # |
| 3 | # MN10300 Context switch operation |
| 4 | # |
| 5 | # Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
| 6 | # Written by David Howells (dhowells@redhat.com) |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or |
| 9 | # modify it under the terms of the GNU General Public Licence |
| 10 | # as published by the Free Software Foundation; either version |
| 11 | # 2 of the Licence, or (at your option) any later version. |
| 12 | # |
| 13 | ############################################################################### |
| 14 | #include <linux/sys.h> |
| 15 | #include <linux/linkage.h> |
| 16 | #include <asm/thread_info.h> |
| 17 | #include <asm/cpu-regs.h> |
Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame^] | 18 | #ifdef CONFIG_SMP |
| 19 | #include <proc/smp-regs.h> |
| 20 | #endif /* CONFIG_SMP */ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 21 | |
| 22 | .text |
| 23 | |
| 24 | ############################################################################### |
| 25 | # |
| 26 | # struct task_struct *__switch_to(struct thread_struct *prev, |
| 27 | # struct thread_struct *next, |
| 28 | # struct task_struct *prev_task) |
| 29 | # |
| 30 | ############################################################################### |
| 31 | ENTRY(__switch_to) |
| 32 | movm [d2,d3,a2,a3,exreg1],(sp) |
| 33 | or EPSW_NMID,epsw |
| 34 | |
| 35 | mov (44,sp),d2 |
| 36 | |
| 37 | mov d0,a0 |
| 38 | mov d1,a1 |
| 39 | |
| 40 | # save prev context |
Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame^] | 41 | #ifdef CONFIG_SMP |
| 42 | mov (CPUID),a2 |
| 43 | add a2,a2 |
| 44 | add a2,a2 |
| 45 | mov (___frame,a2),d0 |
| 46 | #else /* CONFIG_SMP */ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 47 | mov (__frame),d0 |
Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame^] | 48 | #endif /* CONFIG_SMP */ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 49 | mov d0,(THREAD_FRAME,a0) |
| 50 | mov __switch_back,d0 |
| 51 | mov d0,(THREAD_PC,a0) |
| 52 | mov sp,a2 |
| 53 | mov a2,(THREAD_SP,a0) |
| 54 | mov a3,(THREAD_A3,a0) |
| 55 | |
| 56 | mov (THREAD_A3,a1),a3 |
| 57 | mov (THREAD_SP,a1),a2 |
| 58 | |
| 59 | # switch |
| 60 | mov a2,sp |
| 61 | |
| 62 | # load next context |
| 63 | GET_THREAD_INFO a2 |
| 64 | mov a2,(__current_ti) |
| 65 | mov (TI_task,a2),a2 |
| 66 | mov a2,(__current) |
| 67 | #ifdef CONFIG_MN10300_CURRENT_IN_E2 |
| 68 | mov a2,e2 |
| 69 | #endif |
| 70 | |
| 71 | mov (THREAD_FRAME,a1),a2 |
Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame^] | 72 | #ifdef CONFIG_SMP |
| 73 | mov (CPUID),a0 |
| 74 | add a0,a0 |
| 75 | add a0,a0 |
| 76 | mov a2,(___frame,a0) |
| 77 | #else /* CONFIG_SMP */ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 78 | mov a2,(__frame) |
Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame^] | 79 | #endif /* CONFIG_SMP */ |
David Howells | b920de1 | 2008-02-08 04:19:31 -0800 | [diff] [blame] | 80 | mov (THREAD_PC,a1),a2 |
| 81 | mov d2,d0 # for ret_from_fork |
| 82 | mov d0,a0 # for __switch_to |
| 83 | |
| 84 | jmp (a2) |
| 85 | |
| 86 | __switch_back: |
| 87 | and ~EPSW_NMID,epsw |
| 88 | ret [d2,d3,a2,a3,exreg1],32 |