ipipe.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* -*- linux-c -*-
  2. * include/asm-blackfin/ipipe.h
  3. *
  4. * Copyright (C) 2002-2007 Philippe Gerum.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
  9. * USA; either version 2 of the License, or (at your option) any later
  10. * version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __ASM_BLACKFIN_IPIPE_H
  22. #define __ASM_BLACKFIN_IPIPE_H
  23. #ifdef CONFIG_IPIPE
  24. #include <linux/cpumask.h>
  25. #include <linux/list.h>
  26. #include <linux/threads.h>
  27. #include <linux/irq.h>
  28. #include <linux/ipipe_percpu.h>
  29. #include <asm/ptrace.h>
  30. #include <asm/irq.h>
  31. #include <asm/bitops.h>
  32. #include <linux/atomic.h>
  33. #include <asm/traps.h>
  34. #include <asm/bitsperlong.h>
  35. #define IPIPE_ARCH_STRING "1.16-01"
  36. #define IPIPE_MAJOR_NUMBER 1
  37. #define IPIPE_MINOR_NUMBER 16
  38. #define IPIPE_PATCH_NUMBER 1
  39. #ifdef CONFIG_SMP
  40. #error "I-pipe/blackfin: SMP not implemented"
  41. #else /* !CONFIG_SMP */
  42. #define ipipe_processor_id() 0
  43. #endif /* CONFIG_SMP */
  44. #define prepare_arch_switch(next) \
  45. do { \
  46. ipipe_schedule_notify(current, next); \
  47. hard_local_irq_disable(); \
  48. } while (0)
  49. #define task_hijacked(p) \
  50. ({ \
  51. int __x__ = __ipipe_root_domain_p; \
  52. if (__x__) \
  53. hard_local_irq_enable(); \
  54. !__x__; \
  55. })
  56. struct ipipe_domain;
  57. struct ipipe_sysinfo {
  58. int sys_nr_cpus; /* Number of CPUs on board */
  59. int sys_hrtimer_irq; /* hrtimer device IRQ */
  60. u64 sys_hrtimer_freq; /* hrtimer device frequency */
  61. u64 sys_hrclock_freq; /* hrclock device frequency */
  62. u64 sys_cpu_freq; /* CPU frequency (Hz) */
  63. };
  64. #define ipipe_read_tsc(t) \
  65. ({ \
  66. unsigned long __cy2; \
  67. __asm__ __volatile__ ("1: %0 = CYCLES2\n" \
  68. "%1 = CYCLES\n" \
  69. "%2 = CYCLES2\n" \
  70. "CC = %2 == %0\n" \
  71. "if ! CC jump 1b\n" \
  72. : "=d,a" (((unsigned long *)&t)[1]), \
  73. "=d,a" (((unsigned long *)&t)[0]), \
  74. "=d,a" (__cy2) \
  75. : /*no input*/ : "CC"); \
  76. t; \
  77. })
  78. #define ipipe_cpu_freq() __ipipe_core_clock
  79. #define ipipe_tsc2ns(_t) (((unsigned long)(_t)) * __ipipe_freq_scale)
  80. #define ipipe_tsc2us(_t) (ipipe_tsc2ns(_t) / 1000 + 1)
  81. /* Private interface -- Internal use only */
  82. #define __ipipe_check_platform() do { } while (0)
  83. #define __ipipe_init_platform() do { } while (0)
  84. extern atomic_t __ipipe_irq_lvdepth[IVG15 + 1];
  85. extern unsigned long __ipipe_irq_lvmask;
  86. extern struct ipipe_domain ipipe_root;
  87. /* enable/disable_irqdesc _must_ be used in pairs. */
  88. void __ipipe_enable_irqdesc(struct ipipe_domain *ipd,
  89. unsigned irq);
  90. void __ipipe_disable_irqdesc(struct ipipe_domain *ipd,
  91. unsigned irq);
  92. #define __ipipe_enable_irq(irq) \
  93. do { \
  94. struct irq_desc *desc = irq_to_desc(irq); \
  95. struct irq_chip *chip = get_irq_desc_chip(desc); \
  96. chip->irq_unmask(&desc->irq_data); \
  97. } while (0)
  98. #define __ipipe_disable_irq(irq) \
  99. do { \
  100. struct irq_desc *desc = irq_to_desc(irq); \
  101. struct irq_chip *chip = get_irq_desc_chip(desc); \
  102. chip->irq_mask(&desc->irq_data); \
  103. } while (0)
  104. static inline int __ipipe_check_tickdev(const char *devname)
  105. {
  106. return 1;
  107. }
  108. void __ipipe_enable_pipeline(void);
  109. #define __ipipe_hook_critical_ipi(ipd) do { } while (0)
  110. void ___ipipe_sync_pipeline(void);
  111. void __ipipe_handle_irq(unsigned irq, struct pt_regs *regs);
  112. int __ipipe_get_irq_priority(unsigned int irq);
  113. void __ipipe_serial_debug(const char *fmt, ...);
  114. asmlinkage void __ipipe_call_irqtail(unsigned long addr);
  115. DECLARE_PER_CPU(struct pt_regs, __ipipe_tick_regs);
  116. extern unsigned long __ipipe_core_clock;
  117. extern unsigned long __ipipe_freq_scale;
  118. extern unsigned long __ipipe_irq_tail_hook;
  119. static inline unsigned long __ipipe_ffnz(unsigned long ul)
  120. {
  121. return ffs(ul) - 1;
  122. }
  123. #define __ipipe_do_root_xirq(ipd, irq) \
  124. ((ipd)->irqs[irq].handler(irq, &__raw_get_cpu_var(__ipipe_tick_regs)))
  125. #define __ipipe_run_irqtail(irq) /* Must be a macro */ \
  126. do { \
  127. unsigned long __pending; \
  128. CSYNC(); \
  129. __pending = bfin_read_IPEND(); \
  130. if (__pending & 0x8000) { \
  131. __pending &= ~0x8010; \
  132. if (__pending && (__pending & (__pending - 1)) == 0) \
  133. __ipipe_call_irqtail(__ipipe_irq_tail_hook); \
  134. } \
  135. } while (0)
  136. #define __ipipe_syscall_watched_p(p, sc) \
  137. (ipipe_notifier_enabled_p(p) || (unsigned long)sc >= NR_syscalls)
  138. #ifdef CONFIG_BF561
  139. #define bfin_write_TIMER_DISABLE(val) bfin_write_TMRS8_DISABLE(val)
  140. #define bfin_write_TIMER_ENABLE(val) bfin_write_TMRS8_ENABLE(val)
  141. #define bfin_write_TIMER_STATUS(val) bfin_write_TMRS8_STATUS(val)
  142. #define bfin_read_TIMER_STATUS() bfin_read_TMRS8_STATUS()
  143. #elif defined(CONFIG_BF54x)
  144. #define bfin_write_TIMER_DISABLE(val) bfin_write_TIMER_DISABLE0(val)
  145. #define bfin_write_TIMER_ENABLE(val) bfin_write_TIMER_ENABLE0(val)
  146. #define bfin_write_TIMER_STATUS(val) bfin_write_TIMER_STATUS0(val)
  147. #define bfin_read_TIMER_STATUS(val) bfin_read_TIMER_STATUS0(val)
  148. #endif
  149. #define __ipipe_root_tick_p(regs) ((regs->ipend & 0x10) != 0)
  150. #else /* !CONFIG_IPIPE */
  151. #define task_hijacked(p) 0
  152. #define ipipe_trap_notify(t, r) 0
  153. #define __ipipe_root_tick_p(regs) 1
  154. #endif /* !CONFIG_IPIPE */
  155. #ifdef CONFIG_TICKSOURCE_CORETMR
  156. #define IRQ_SYSTMR IRQ_CORETMR
  157. #define IRQ_PRIOTMR IRQ_CORETMR
  158. #else
  159. #define IRQ_SYSTMR IRQ_TIMER0
  160. #define IRQ_PRIOTMR CONFIG_IRQ_TIMER0
  161. #endif
  162. #define ipipe_update_tick_evtdev(evtdev) do { } while (0)
  163. #endif /* !__ASM_BLACKFIN_IPIPE_H */