irq.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. /*
  30. * IRQ line status macro IRQ_PER_CPU is used
  31. */
  32. #define ARCH_HAS_IRQ_PER_CPU
  33. #define get_irq_desc(irq) (&irq_desc[(irq)])
  34. /* Define a way to iterate across irqs. */
  35. #define for_each_irq(i) \
  36. for ((i) = 0; (i) < NR_IRQS; ++(i))
  37. /* Interrupt numbers are virtual in case they are sparsely
  38. * distributed by the hardware.
  39. */
  40. extern unsigned int virt_irq_to_real_map[NR_IRQS];
  41. /* Create a mapping for a real_irq if it doesn't already exist.
  42. * Return the virtual irq as a convenience.
  43. */
  44. int virt_irq_create_mapping(unsigned int real_irq);
  45. void virt_irq_init(void);
  46. static inline unsigned int virt_irq_to_real(unsigned int virt_irq)
  47. {
  48. return virt_irq_to_real_map[virt_irq];
  49. }
  50. extern unsigned int real_irq_to_virt_slowpath(unsigned int real_irq);
  51. /*
  52. * Because many systems have two overlapping names spaces for
  53. * interrupts (ISA and XICS for example), and the ISA interrupts
  54. * have historically not been easy to renumber, we allow ISA
  55. * interrupts to take values 0 - 15, and shift up the remaining
  56. * interrupts by 0x10.
  57. */
  58. #define NUM_ISA_INTERRUPTS 0x10
  59. extern int __irq_offset_value;
  60. static inline int irq_offset_up(int irq)
  61. {
  62. return(irq + __irq_offset_value);
  63. }
  64. static inline int irq_offset_down(int irq)
  65. {
  66. return(irq - __irq_offset_value);
  67. }
  68. static inline int irq_offset_value(void)
  69. {
  70. return __irq_offset_value;
  71. }
  72. static __inline__ int irq_canonicalize(int irq)
  73. {
  74. return irq;
  75. }
  76. extern int distribute_irqs;
  77. struct irqaction;
  78. struct pt_regs;
  79. #ifdef CONFIG_IRQSTACKS
  80. /*
  81. * Per-cpu stacks for handling hard and soft interrupts.
  82. */
  83. extern struct thread_info *hardirq_ctx[NR_CPUS];
  84. extern struct thread_info *softirq_ctx[NR_CPUS];
  85. extern void irq_ctx_init(void);
  86. extern void call_do_softirq(struct thread_info *tp);
  87. extern int call_handle_IRQ_event(int irq, struct pt_regs *regs,
  88. struct irqaction *action, struct thread_info *tp);
  89. #define __ARCH_HAS_DO_SOFTIRQ
  90. #else
  91. #define irq_ctx_init()
  92. #endif /* CONFIG_IRQSTACKS */
  93. #endif /* _ASM_IRQ_H */
  94. #endif /* __KERNEL__ */