system.h 1.8 KB

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