system.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _ASM_SCORE_SYSTEM_H
  2. #define _ASM_SCORE_SYSTEM_H
  3. #include <linux/types.h>
  4. #include <linux/irqflags.h>
  5. struct pt_regs;
  6. struct task_struct;
  7. extern void *resume(void *last, void *next, void *next_ti);
  8. #define switch_to(prev, next, last) \
  9. do { \
  10. (last) = resume(prev, next, task_thread_info(next)); \
  11. } while (0)
  12. #define finish_arch_switch(prev) do {} while (0)
  13. typedef void (*vi_handler_t)(void);
  14. extern unsigned long arch_align_stack(unsigned long sp);
  15. #define mb() barrier()
  16. #define rmb() barrier()
  17. #define wmb() barrier()
  18. #define smp_mb() barrier()
  19. #define smp_rmb() barrier()
  20. #define smp_wmb() barrier()
  21. #define read_barrier_depends() do {} while (0)
  22. #define smp_read_barrier_depends() do {} while (0)
  23. #define set_mb(var, value) do {var = value; wmb(); } while (0)
  24. #define __HAVE_ARCH_CMPXCHG 1
  25. #include <asm-generic/cmpxchg-local.h>
  26. #ifndef __ASSEMBLY__
  27. struct __xchg_dummy { unsigned long a[100]; };
  28. #define __xg(x) ((struct __xchg_dummy *)(x))
  29. static inline
  30. unsigned long __xchg(volatile unsigned long *m, unsigned long val)
  31. {
  32. unsigned long retval;
  33. unsigned long flags;
  34. local_irq_save(flags);
  35. retval = *m;
  36. *m = val;
  37. local_irq_restore(flags);
  38. return retval;
  39. }
  40. #define xchg(ptr, v) \
  41. ((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr), \
  42. (unsigned long)(v)))
  43. static inline unsigned long __cmpxchg(volatile unsigned long *m,
  44. unsigned long old, unsigned long new)
  45. {
  46. unsigned long retval;
  47. unsigned long flags;
  48. local_irq_save(flags);
  49. retval = *m;
  50. if (retval == old)
  51. *m = new;
  52. local_irq_restore(flags);
  53. return retval;
  54. }
  55. #define cmpxchg(ptr, o, n) \
  56. ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
  57. (unsigned long)(o), \
  58. (unsigned long)(n)))
  59. extern void __die(const char *, struct pt_regs *, const char *,
  60. const char *, unsigned long) __attribute__((noreturn));
  61. extern void __die_if_kernel(const char *, struct pt_regs *, const char *,
  62. const char *, unsigned long);
  63. #define die(msg, regs) \
  64. __die(msg, regs, __FILE__ ":", __func__, __LINE__)
  65. #define die_if_kernel(msg, regs) \
  66. __die_if_kernel(msg, regs, __FILE__ ":", __func__, __LINE__)
  67. #endif /* !__ASSEMBLY__ */
  68. #endif /* _ASM_SCORE_SYSTEM_H */