system.h 2.4 KB

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