David Howells | 1c80f22 | 2012-03-28 18:30:02 +0100 | [diff] [blame^] | 1 | /* MN10300 task switching definitions |
| 2 | * |
| 3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | #ifndef _ASM_SWITCH_TO_H |
| 12 | #define _ASM_SWITCH_TO_H |
| 13 | |
| 14 | #include <asm/barrier.h> |
| 15 | |
| 16 | struct task_struct; |
| 17 | struct thread_struct; |
| 18 | |
| 19 | #if !defined(CONFIG_LAZY_SAVE_FPU) |
| 20 | struct fpu_state_struct; |
| 21 | extern asmlinkage void fpu_save(struct fpu_state_struct *); |
| 22 | #define switch_fpu(prev, next) \ |
| 23 | do { \ |
| 24 | if ((prev)->thread.fpu_flags & THREAD_HAS_FPU) { \ |
| 25 | (prev)->thread.fpu_flags &= ~THREAD_HAS_FPU; \ |
| 26 | (prev)->thread.uregs->epsw &= ~EPSW_FE; \ |
| 27 | fpu_save(&(prev)->thread.fpu_state); \ |
| 28 | } \ |
| 29 | } while (0) |
| 30 | #else |
| 31 | #define switch_fpu(prev, next) do {} while (0) |
| 32 | #endif |
| 33 | |
| 34 | /* context switching is now performed out-of-line in switch_to.S */ |
| 35 | extern asmlinkage |
| 36 | struct task_struct *__switch_to(struct thread_struct *prev, |
| 37 | struct thread_struct *next, |
| 38 | struct task_struct *prev_task); |
| 39 | |
| 40 | #define switch_to(prev, next, last) \ |
| 41 | do { \ |
| 42 | switch_fpu(prev, next); \ |
| 43 | current->thread.wchan = (u_long) __builtin_return_address(0); \ |
| 44 | (last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \ |
| 45 | mb(); \ |
| 46 | current->thread.wchan = 0; \ |
| 47 | } while (0) |
| 48 | |
| 49 | #endif /* _ASM_SWITCH_TO_H */ |