Commit | Line | Data |
---|---|---|
51533b61 MS |
1 | #ifndef _ASM_CRIS_ARCH_SYSTEM_H |
2 | #define _ASM_CRIS_ARCH_SYSTEM_H | |
3 | ||
51533b61 MS |
4 | |
5 | /* Read the CPU version register. */ | |
d9b5444e | 6 | static inline unsigned long rdvr(void) |
51533b61 MS |
7 | { |
8 | unsigned char vr; | |
9 | ||
10 | __asm__ __volatile__ ("move $vr, %0" : "=rm" (vr)); | |
11 | return vr; | |
12 | } | |
13 | ||
14 | #define cris_machine_name "crisv32" | |
15 | ||
16 | /* Read the user-mode stack pointer. */ | |
d9b5444e | 17 | static inline unsigned long rdusp(void) |
51533b61 MS |
18 | { |
19 | unsigned long usp; | |
20 | ||
21 | __asm__ __volatile__ ("move $usp, %0" : "=rm" (usp)); | |
22 | return usp; | |
23 | } | |
24 | ||
25 | /* Read the current stack pointer. */ | |
d9b5444e | 26 | static inline unsigned long rdsp(void) |
51533b61 MS |
27 | { |
28 | unsigned long sp; | |
29 | ||
30 | __asm__ __volatile__ ("move.d $sp, %0" : "=rm" (sp)); | |
31 | return sp; | |
32 | } | |
33 | ||
34 | /* Write the user-mode stack pointer. */ | |
35 | #define wrusp(usp) __asm__ __volatile__ ("move %0, $usp" : : "rm" (usp)) | |
36 | ||
37 | #define nop() __asm__ __volatile__ ("nop"); | |
38 | ||
39 | #define xchg(ptr,x) \ | |
40 | ((__typeof__(*(ptr)))__xchg((unsigned long) (x),(ptr),sizeof(*(ptr)))) | |
41 | ||
42 | #define tas(ptr) (xchg((ptr),1)) | |
43 | ||
44 | struct __xchg_dummy { unsigned long a[100]; }; | |
45 | #define __xg(x) ((struct __xchg_dummy *)(x)) | |
46 | ||
47 | /* Used for interrupt control. */ | |
48 | #define local_save_flags(x) \ | |
49 | __asm__ __volatile__ ("move $ccs, %0" : "=rm" (x) : : "memory"); | |
50 | ||
51 | #define local_irq_restore(x) \ | |
52 | __asm__ __volatile__ ("move %0, $ccs" : : "rm" (x) : "memory"); | |
53 | ||
54 | #define local_irq_disable() __asm__ __volatile__ ("di" : : : "memory"); | |
55 | #define local_irq_enable() __asm__ __volatile__ ("ei" : : : "memory"); | |
56 | ||
57 | #define irqs_disabled() \ | |
58 | ({ \ | |
59 | unsigned long flags; \ | |
60 | \ | |
61 | local_save_flags(flags);\ | |
62 | !(flags & (1 << I_CCS_BITNR)); \ | |
63 | }) | |
64 | ||
65 | /* Used for spinlocks, etc. */ | |
66 | #define local_irq_save(x) \ | |
67 | __asm__ __volatile__ ("move $ccs, %0\n\tdi" : "=rm" (x) : : "memory"); | |
68 | ||
51533b61 | 69 | #endif /* _ASM_CRIS_ARCH_SYSTEM_H */ |