blob: 6cc35642b8ab0d08c6182ba6256f8a642fe85299 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_CRIS_ARCH_SYSTEM_H
2#define __ASM_CRIS_ARCH_SYSTEM_H
3
4#include <linux/config.h>
5
6/* read the CPU version register */
7
8extern inline unsigned long rdvr(void) {
9 unsigned char vr;
10 __asm__ volatile ("move $vr,%0" : "=rm" (vr));
11 return vr;
12}
13
Mikael Starvik7cf32ca2005-07-27 11:44:38 -070014#define cris_machine_name "cris"
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016/* read/write the user-mode stackpointer */
17
18extern inline unsigned long rdusp(void) {
19 unsigned long usp;
20 __asm__ __volatile__("move $usp,%0" : "=rm" (usp));
21 return usp;
22}
23
24#define wrusp(usp) \
25 __asm__ __volatile__("move %0,$usp" : /* no outputs */ : "rm" (usp))
26
27/* read the current stackpointer */
28
29extern inline unsigned long rdsp(void) {
30 unsigned long sp;
31 __asm__ __volatile__("move.d $sp,%0" : "=rm" (sp));
32 return sp;
33}
34
35extern inline unsigned long _get_base(char * addr)
36{
37 return 0;
38}
39
40#define nop() __asm__ __volatile__ ("nop");
41
42#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
43#define tas(ptr) (xchg((ptr),1))
44
45struct __xchg_dummy { unsigned long a[100]; };
46#define __xg(x) ((struct __xchg_dummy *)(x))
47
48/* interrupt control.. */
49#define local_save_flags(x) __asm__ __volatile__ ("move $ccr,%0" : "=rm" (x) : : "memory");
50#define local_irq_restore(x) __asm__ __volatile__ ("move %0,$ccr" : : "rm" (x) : "memory");
51#define local_irq_disable() __asm__ __volatile__ ( "di" : : :"memory");
52#define local_irq_enable() __asm__ __volatile__ ( "ei" : : :"memory");
53
54#define irqs_disabled() \
55({ \
56 unsigned long flags; \
57 local_save_flags(flags); \
58 !(flags & (1<<5)); \
59})
60
61/* For spinlocks etc */
62#define local_irq_save(x) __asm__ __volatile__ ("move $ccr,%0\n\tdi" : "=rm" (x) : : "memory");
63
64#endif