Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_CRIS_ARCH_SYSTEM_H |
| 2 | #define __ASM_CRIS_ARCH_SYSTEM_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
| 5 | /* read the CPU version register */ |
| 6 | |
Adrian Bunk | d9b5444 | 2005-11-07 00:58:44 -0800 | [diff] [blame] | 7 | static inline unsigned long rdvr(void) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | unsigned char vr; |
| 9 | __asm__ volatile ("move $vr,%0" : "=rm" (vr)); |
| 10 | return vr; |
| 11 | } |
| 12 | |
Mikael Starvik | 7cf32ca | 2005-07-27 11:44:38 -0700 | [diff] [blame] | 13 | #define cris_machine_name "cris" |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | /* read/write the user-mode stackpointer */ |
| 16 | |
Adrian Bunk | d9b5444 | 2005-11-07 00:58:44 -0800 | [diff] [blame] | 17 | static inline unsigned long rdusp(void) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | unsigned long usp; |
| 19 | __asm__ __volatile__("move $usp,%0" : "=rm" (usp)); |
| 20 | return usp; |
| 21 | } |
| 22 | |
| 23 | #define wrusp(usp) \ |
| 24 | __asm__ __volatile__("move %0,$usp" : /* no outputs */ : "rm" (usp)) |
| 25 | |
| 26 | /* read the current stackpointer */ |
| 27 | |
Adrian Bunk | d9b5444 | 2005-11-07 00:58:44 -0800 | [diff] [blame] | 28 | static inline unsigned long rdsp(void) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | unsigned long sp; |
| 30 | __asm__ __volatile__("move.d $sp,%0" : "=rm" (sp)); |
| 31 | return sp; |
| 32 | } |
| 33 | |
Adrian Bunk | d9b5444 | 2005-11-07 00:58:44 -0800 | [diff] [blame] | 34 | static inline unsigned long _get_base(char * addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | #define nop() __asm__ __volatile__ ("nop"); |
| 40 | |
| 41 | #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) |
| 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 | /* interrupt control.. */ |
| 48 | #define local_save_flags(x) __asm__ __volatile__ ("move $ccr,%0" : "=rm" (x) : : "memory"); |
| 49 | #define local_irq_restore(x) __asm__ __volatile__ ("move %0,$ccr" : : "rm" (x) : "memory"); |
| 50 | #define local_irq_disable() __asm__ __volatile__ ( "di" : : :"memory"); |
| 51 | #define local_irq_enable() __asm__ __volatile__ ( "ei" : : :"memory"); |
| 52 | |
| 53 | #define irqs_disabled() \ |
| 54 | ({ \ |
| 55 | unsigned long flags; \ |
| 56 | local_save_flags(flags); \ |
| 57 | !(flags & (1<<5)); \ |
| 58 | }) |
| 59 | |
| 60 | /* For spinlocks etc */ |
| 61 | #define local_irq_save(x) __asm__ __volatile__ ("move $ccr,%0\n\tdi" : "=rm" (x) : : "memory"); |
| 62 | |
| 63 | #endif |