irq.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #ifndef _LINUX_IRQ_H
  2. #define _LINUX_IRQ_H
  3. /*
  4. * Please do not include this file in generic code. There is currently
  5. * no requirement for any architecture to implement anything held
  6. * within this file.
  7. *
  8. * Thanks. --rmk
  9. */
  10. #include <linux/smp.h>
  11. #ifndef CONFIG_S390
  12. #include <linux/linkage.h>
  13. #include <linux/cache.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/cpumask.h>
  16. #include <linux/irqreturn.h>
  17. #include <asm/irq.h>
  18. #include <asm/ptrace.h>
  19. /*
  20. * IRQ line status.
  21. */
  22. #define IRQ_INPROGRESS 1 /* IRQ handler active - do not enter! */
  23. #define IRQ_DISABLED 2 /* IRQ disabled - do not enter! */
  24. #define IRQ_PENDING 4 /* IRQ pending - replay on enable */
  25. #define IRQ_REPLAY 8 /* IRQ has been replayed but not acked yet */
  26. #define IRQ_AUTODETECT 16 /* IRQ is being autodetected */
  27. #define IRQ_WAITING 32 /* IRQ not yet seen - for autodetection */
  28. #define IRQ_LEVEL 64 /* IRQ level triggered */
  29. #define IRQ_MASKED 128 /* IRQ masked - shouldn't be seen again */
  30. #ifdef CONFIG_IRQ_PER_CPU
  31. # define IRQ_PER_CPU 256 /* IRQ is per CPU */
  32. # define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
  33. #else
  34. # define CHECK_IRQ_PER_CPU(var) 0
  35. #endif
  36. /*
  37. * Interrupt controller descriptor. This is all we need
  38. * to describe about the low-level hardware.
  39. */
  40. struct hw_interrupt_type {
  41. const char *typename;
  42. unsigned int (*startup)(unsigned int irq);
  43. void (*shutdown)(unsigned int irq);
  44. void (*enable)(unsigned int irq);
  45. void (*disable)(unsigned int irq);
  46. void (*ack)(unsigned int irq);
  47. void (*end)(unsigned int irq);
  48. void (*set_affinity)(unsigned int irq, cpumask_t dest);
  49. int (*retrigger)(unsigned int irq);
  50. /* Currently used only by UML, might disappear one day.*/
  51. #ifdef CONFIG_IRQ_RELEASE_METHOD
  52. void (*release)(unsigned int irq, void *dev_id);
  53. #endif
  54. };
  55. typedef struct hw_interrupt_type hw_irq_controller;
  56. struct proc_dir_entry;
  57. /*
  58. * This is the "IRQ descriptor", which contains various information
  59. * about the irq, including what kind of hardware handling it has,
  60. * whether it is disabled etc etc.
  61. *
  62. * Pad this out to 32 bytes for cache and indexing reasons.
  63. */
  64. struct irq_desc {
  65. hw_irq_controller *chip;
  66. void *chip_data;
  67. struct irqaction *action; /* IRQ action list */
  68. unsigned int status; /* IRQ status */
  69. unsigned int depth; /* nested irq disables */
  70. unsigned int irq_count; /* For detecting broken IRQs */
  71. unsigned int irqs_unhandled;
  72. spinlock_t lock;
  73. #ifdef CONFIG_SMP
  74. cpumask_t affinity;
  75. #endif
  76. #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
  77. cpumask_t pending_mask;
  78. unsigned int move_irq; /* need to re-target IRQ dest */
  79. #endif
  80. #ifdef CONFIG_PROC_FS
  81. struct proc_dir_entry *dir;
  82. #endif
  83. } ____cacheline_aligned;
  84. extern struct irq_desc irq_desc[NR_IRQS];
  85. /*
  86. * Migration helpers for obsolete names, they will go away:
  87. */
  88. typedef struct irq_desc irq_desc_t;
  89. /*
  90. * Pick up the arch-dependent methods:
  91. */
  92. #include <asm/hw_irq.h>
  93. extern int setup_irq(unsigned int irq, struct irqaction *new);
  94. #ifdef CONFIG_GENERIC_HARDIRQS
  95. #ifdef CONFIG_SMP
  96. static inline void set_native_irq_info(int irq, cpumask_t mask)
  97. {
  98. irq_desc[irq].affinity = mask;
  99. }
  100. #else
  101. static inline void set_native_irq_info(int irq, cpumask_t mask)
  102. {
  103. }
  104. #endif
  105. #ifdef CONFIG_SMP
  106. #if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
  107. void set_pending_irq(unsigned int irq, cpumask_t mask);
  108. void move_native_irq(int irq);
  109. #ifdef CONFIG_PCI_MSI
  110. /*
  111. * Wonder why these are dummies?
  112. * For e.g the set_ioapic_affinity_vector() calls the set_ioapic_affinity_irq()
  113. * counter part after translating the vector to irq info. We need to perform
  114. * this operation on the real irq, when we dont use vector, i.e when
  115. * pci_use_vector() is false.
  116. */
  117. static inline void move_irq(int irq)
  118. {
  119. }
  120. static inline void set_irq_info(int irq, cpumask_t mask)
  121. {
  122. }
  123. #else /* CONFIG_PCI_MSI */
  124. static inline void move_irq(int irq)
  125. {
  126. move_native_irq(irq);
  127. }
  128. static inline void set_irq_info(int irq, cpumask_t mask)
  129. {
  130. set_native_irq_info(irq, mask);
  131. }
  132. #endif /* CONFIG_PCI_MSI */
  133. #else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */
  134. static inline void move_irq(int irq)
  135. {
  136. }
  137. static inline void move_native_irq(int irq)
  138. {
  139. }
  140. static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
  141. {
  142. }
  143. static inline void set_irq_info(int irq, cpumask_t mask)
  144. {
  145. set_native_irq_info(irq, mask);
  146. }
  147. #endif /* CONFIG_GENERIC_PENDING_IRQ */
  148. #else /* CONFIG_SMP */
  149. #define move_irq(x)
  150. #define move_native_irq(x)
  151. #endif /* CONFIG_SMP */
  152. #ifdef CONFIG_IRQBALANCE
  153. extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
  154. #else
  155. static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
  156. {
  157. }
  158. #endif
  159. #ifdef CONFIG_AUTO_IRQ_AFFINITY
  160. extern int select_smp_affinity(unsigned int irq);
  161. #else
  162. static inline int select_smp_affinity(unsigned int irq)
  163. {
  164. return 1;
  165. }
  166. #endif
  167. extern int no_irq_affinity;
  168. extern int noirqdebug_setup(char *str);
  169. extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
  170. struct irqaction *action);
  171. /*
  172. * Explicit fastcall, because i386 4KSTACKS calls it from assembly:
  173. */
  174. extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
  175. extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
  176. int action_ret, struct pt_regs *regs);
  177. extern int can_request_irq(unsigned int irq, unsigned long irqflags);
  178. extern void init_irq_proc(void);
  179. #endif /* CONFIG_GENERIC_HARDIRQS */
  180. extern hw_irq_controller no_irq_type; /* needed in every arch ? */
  181. #endif /* !CONFIG_S390 */
  182. #endif /* _LINUX_IRQ_H */