blob: 7de90bc4cf8093507a00286cfeb2fa8b8edf1c5d [file] [log] [blame]
David Howellsb920de12008-02-08 04:19:31 -08001/* MN10300 System 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_SYSTEM_H
12#define _ASM_SYSTEM_H
13
14#include <asm/cpu-regs.h>
15
16#ifdef __KERNEL__
17#ifndef __ASSEMBLY__
18
19#include <linux/kernel.h>
David Howellsdf9ee292010-10-07 14:08:55 +010020#include <linux/irqflags.h>
Mark Salter4f81ca12010-10-27 17:28:52 +010021#include <asm/atomic.h>
David Howellsb920de12008-02-08 04:19:31 -080022
Akira Takeuchi278d91c2010-10-27 17:28:52 +010023#if !defined(CONFIG_LAZY_SAVE_FPU)
24struct fpu_state_struct;
25extern asmlinkage void fpu_save(struct fpu_state_struct *);
26#define switch_fpu(prev, next) \
27 do { \
28 if ((prev)->thread.fpu_flags & THREAD_HAS_FPU) { \
29 (prev)->thread.fpu_flags &= ~THREAD_HAS_FPU; \
30 (prev)->thread.uregs->epsw &= ~EPSW_FE; \
31 fpu_save(&(prev)->thread.fpu_state); \
32 } \
33 } while (0)
34#else
35#define switch_fpu(prev, next) do {} while (0)
36#endif
37
David Howellsb920de12008-02-08 04:19:31 -080038struct task_struct;
39struct thread_struct;
40
41extern asmlinkage
42struct task_struct *__switch_to(struct thread_struct *prev,
43 struct thread_struct *next,
44 struct task_struct *prev_task);
45
46/* context switching is now performed out-of-line in switch_to.S */
47#define switch_to(prev, next, last) \
48do { \
Akira Takeuchi278d91c2010-10-27 17:28:52 +010049 switch_fpu(prev, next); \
David Howellsb920de12008-02-08 04:19:31 -080050 current->thread.wchan = (u_long) __builtin_return_address(0); \
51 (last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \
52 mb(); \
53 current->thread.wchan = 0; \
54} while (0)
55
56#define arch_align_stack(x) (x)
57
58#define nop() asm volatile ("nop")
59
60#endif /* !__ASSEMBLY__ */
61
62/*
63 * Force strict CPU ordering.
64 * And yes, this is required on UP too when we're talking
65 * to devices.
66 *
67 * For now, "wmb()" doesn't actually do anything, as all
68 * Intel CPU's follow what Intel calls a *Processor Order*,
69 * in which all writes are seen in the program order even
70 * outside the CPU.
71 *
72 * I expect future Intel CPU's to have a weaker ordering,
73 * but I'd also expect them to finally get their act together
74 * and add some real memory barriers if so.
75 *
76 * Some non intel clones support out of order store. wmb() ceases to be a
77 * nop for these.
78 */
79
80#define mb() asm volatile ("": : :"memory")
81#define rmb() mb()
82#define wmb() asm volatile ("": : :"memory")
83
84#ifdef CONFIG_SMP
85#define smp_mb() mb()
86#define smp_rmb() rmb()
87#define smp_wmb() wmb()
88#else
89#define smp_mb() barrier()
90#define smp_rmb() barrier()
91#define smp_wmb() barrier()
92#endif
93
94#define set_mb(var, value) do { var = value; mb(); } while (0)
95#define set_wmb(var, value) do { var = value; wmb(); } while (0)
96
97#define read_barrier_depends() do {} while (0)
98#define smp_read_barrier_depends() do {} while (0)
99
David Howellsb920de12008-02-08 04:19:31 -0800100#endif /* __KERNEL__ */
101#endif /* _ASM_SYSTEM_H */