irq.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifdef __KERNEL__
  2. #ifndef _ASM_IRQ_H
  3. #define _ASM_IRQ_H
  4. /*
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/threads.h>
  12. /*
  13. * Maximum number of interrupt sources that we can handle.
  14. */
  15. #define NR_IRQS 512
  16. /* this number is used when no interrupt has been assigned */
  17. #define NO_IRQ (-1)
  18. /*
  19. * These constants are used for passing information about interrupt
  20. * signal polarity and level/edge sensing to the low-level PIC chip
  21. * drivers.
  22. */
  23. #define IRQ_SENSE_MASK 0x1
  24. #define IRQ_SENSE_LEVEL 0x1 /* interrupt on active level */
  25. #define IRQ_SENSE_EDGE 0x0 /* interrupt triggered by edge */
  26. #define IRQ_POLARITY_MASK 0x2
  27. #define IRQ_POLARITY_POSITIVE 0x2 /* high level or low->high edge */
  28. #define IRQ_POLARITY_NEGATIVE 0x0 /* low level or high->low edge */
  29. #define get_irq_desc(irq) (&irq_desc[(irq)])
  30. /* Define a way to iterate across irqs. */
  31. #define for_each_irq(i) \
  32. for ((i) = 0; (i) < NR_IRQS; ++(i))
  33. /* Interrupt numbers are virtual in case they are sparsely
  34. * distributed by the hardware.
  35. */
  36. extern unsigned int virt_irq_to_real_map[NR_IRQS];
  37. /* Create a mapping for a real_irq if it doesn't already exist.
  38. * Return the virtual irq as a convenience.
  39. */
  40. int virt_irq_create_mapping(unsigned int real_irq);
  41. void virt_irq_init(void);
  42. static inline unsigned int virt_irq_to_real(unsigned int virt_irq)
  43. {
  44. return virt_irq_to_real_map[virt_irq];
  45. }
  46. extern unsigned int real_irq_to_virt_slowpath(unsigned int real_irq);
  47. /*
  48. * Because many systems have two overlapping names spaces for
  49. * interrupts (ISA and XICS for example), and the ISA interrupts
  50. * have historically not been easy to renumber, we allow ISA
  51. * interrupts to take values 0 - 15, and shift up the remaining
  52. * interrupts by 0x10.
  53. */
  54. #define NUM_ISA_INTERRUPTS 0x10
  55. extern int __irq_offset_value;
  56. static inline int irq_offset_up(int irq)
  57. {
  58. return(irq + __irq_offset_value);
  59. }
  60. static inline int irq_offset_down(int irq)
  61. {
  62. return(irq - __irq_offset_value);
  63. }
  64. static inline int irq_offset_value(void)
  65. {
  66. return __irq_offset_value;
  67. }
  68. static __inline__ int irq_canonicalize(int irq)
  69. {
  70. return irq;
  71. }
  72. extern int distribute_irqs;
  73. struct irqaction;
  74. struct pt_regs;
  75. #ifdef CONFIG_IRQSTACKS
  76. /*
  77. * Per-cpu stacks for handling hard and soft interrupts.
  78. */
  79. extern struct thread_info *hardirq_ctx[NR_CPUS];
  80. extern struct thread_info *softirq_ctx[NR_CPUS];
  81. extern void irq_ctx_init(void);
  82. extern void call_do_softirq(struct thread_info *tp);
  83. extern int call_handle_IRQ_event(int irq, struct pt_regs *regs,
  84. struct irqaction *action, struct thread_info *tp);
  85. #define __ARCH_HAS_DO_SOFTIRQ
  86. #else
  87. #define irq_ctx_init()
  88. #endif /* CONFIG_IRQSTACKS */
  89. #endif /* _ASM_IRQ_H */
  90. #endif /* __KERNEL__ */