blob: b869f6161aaa1c73e770fb2f238eecc7894654d9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_CRIS_SYSTEM_H
2#define __ASM_CRIS_SYSTEM_H
3
4#include <asm/arch/system.h>
5
6/* the switch_to macro calls resume, an asm function in entry.S which does the actual
7 * task switching.
8 */
9
10extern struct task_struct *resume(struct task_struct *prev, struct task_struct *next, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#define switch_to(prev,next,last) last = resume(prev,next, \
12 (int)&((struct task_struct *)0)->thread)
13
14#define barrier() __asm__ __volatile__("": : :"memory")
15#define mb() barrier()
16#define rmb() mb()
17#define wmb() mb()
18#define read_barrier_depends() do { } while(0)
19#define set_mb(var, value) do { var = value; mb(); } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#ifdef CONFIG_SMP
22#define smp_mb() mb()
23#define smp_rmb() rmb()
24#define smp_wmb() wmb()
25#define smp_read_barrier_depends() read_barrier_depends()
26#else
27#define smp_mb() barrier()
28#define smp_rmb() barrier()
29#define smp_wmb() barrier()
30#define smp_read_barrier_depends() do { } while(0)
31#endif
32
33#define iret()
34
35/*
36 * disable hlt during certain critical i/o operations
37 */
38#define HAVE_DISABLE_HLT
39void disable_hlt(void);
40void enable_hlt(void);
41
Adrian Bunkd9b54442005-11-07 00:58:44 -080042static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
44 /* since Etrax doesn't have any atomic xchg instructions, we need to disable
45 irq's (if enabled) and do it with move.d's */
46 unsigned long flags,temp;
47 local_save_flags(flags); /* save flags, including irq enable bit */
48 local_irq_disable(); /* shut off irq's */
49 switch (size) {
50 case 1:
51 *((unsigned char *)&temp) = x;
52 x = *(unsigned char *)ptr;
53 *(unsigned char *)ptr = *((unsigned char *)&temp);
54 break;
55 case 2:
56 *((unsigned short *)&temp) = x;
57 x = *(unsigned short *)ptr;
58 *(unsigned short *)ptr = *((unsigned short *)&temp);
59 break;
60 case 4:
61 temp = x;
62 x = *(unsigned long *)ptr;
63 *(unsigned long *)ptr = temp;
64 break;
65 }
66 local_irq_restore(flags); /* restore irq enable bit */
67 return x;
68}
69
70#define arch_align_stack(x) (x)
71
Adrian Bunkcdb04522006-03-24 03:15:57 -080072void default_idle(void);
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#endif