io_apic.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #ifndef _ASM_X86_IO_APIC_H
  2. #define _ASM_X86_IO_APIC_H
  3. #include <linux/types.h>
  4. #include <asm/mpspec.h>
  5. #include <asm/apicdef.h>
  6. #include <asm/irq_vectors.h>
  7. /*
  8. * Intel IO-APIC support for SMP and UP systems.
  9. *
  10. * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
  11. */
  12. /* I/O Unit Redirection Table */
  13. #define IO_APIC_REDIR_VECTOR_MASK 0x000FF
  14. #define IO_APIC_REDIR_DEST_LOGICAL 0x00800
  15. #define IO_APIC_REDIR_DEST_PHYSICAL 0x00000
  16. #define IO_APIC_REDIR_SEND_PENDING (1 << 12)
  17. #define IO_APIC_REDIR_REMOTE_IRR (1 << 14)
  18. #define IO_APIC_REDIR_LEVEL_TRIGGER (1 << 15)
  19. #define IO_APIC_REDIR_MASKED (1 << 16)
  20. struct io_apic_ops {
  21. void (*init) (void);
  22. unsigned int (*read) (unsigned int apic, unsigned int reg);
  23. void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
  24. void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
  25. };
  26. void __init set_io_apic_ops(const struct io_apic_ops *);
  27. /*
  28. * The structure of the IO-APIC:
  29. */
  30. union IO_APIC_reg_00 {
  31. u32 raw;
  32. struct {
  33. u32 __reserved_2 : 14,
  34. LTS : 1,
  35. delivery_type : 1,
  36. __reserved_1 : 8,
  37. ID : 8;
  38. } __attribute__ ((packed)) bits;
  39. };
  40. union IO_APIC_reg_01 {
  41. u32 raw;
  42. struct {
  43. u32 version : 8,
  44. __reserved_2 : 7,
  45. PRQ : 1,
  46. entries : 8,
  47. __reserved_1 : 8;
  48. } __attribute__ ((packed)) bits;
  49. };
  50. union IO_APIC_reg_02 {
  51. u32 raw;
  52. struct {
  53. u32 __reserved_2 : 24,
  54. arbitration : 4,
  55. __reserved_1 : 4;
  56. } __attribute__ ((packed)) bits;
  57. };
  58. union IO_APIC_reg_03 {
  59. u32 raw;
  60. struct {
  61. u32 boot_DT : 1,
  62. __reserved_1 : 31;
  63. } __attribute__ ((packed)) bits;
  64. };
  65. struct IO_APIC_route_entry {
  66. __u32 vector : 8,
  67. delivery_mode : 3, /* 000: FIXED
  68. * 001: lowest prio
  69. * 111: ExtINT
  70. */
  71. dest_mode : 1, /* 0: physical, 1: logical */
  72. delivery_status : 1,
  73. polarity : 1,
  74. irr : 1,
  75. trigger : 1, /* 0: edge, 1: level */
  76. mask : 1, /* 0: enabled, 1: disabled */
  77. __reserved_2 : 15;
  78. __u32 __reserved_3 : 24,
  79. dest : 8;
  80. } __attribute__ ((packed));
  81. struct IR_IO_APIC_route_entry {
  82. __u64 vector : 8,
  83. zero : 3,
  84. index2 : 1,
  85. delivery_status : 1,
  86. polarity : 1,
  87. irr : 1,
  88. trigger : 1,
  89. mask : 1,
  90. reserved : 31,
  91. format : 1,
  92. index : 15;
  93. } __attribute__ ((packed));
  94. #define IOAPIC_AUTO -1
  95. #define IOAPIC_EDGE 0
  96. #define IOAPIC_LEVEL 1
  97. #ifdef CONFIG_X86_IO_APIC
  98. /*
  99. * # of IO-APICs and # of IRQ routing registers
  100. */
  101. extern int nr_ioapics;
  102. extern int mpc_ioapic_id(int ioapic);
  103. extern unsigned int mpc_ioapic_addr(int ioapic);
  104. extern struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int ioapic);
  105. #define MP_MAX_IOAPIC_PIN 127
  106. /* # of MP IRQ source entries */
  107. extern int mp_irq_entries;
  108. /* MP IRQ source entries */
  109. extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];
  110. /* non-0 if default (table-less) MP configuration */
  111. extern int mpc_default_type;
  112. /* Older SiS APIC requires we rewrite the index register */
  113. extern int sis_apic_bug;
  114. /* 1 if "noapic" boot option passed */
  115. extern int skip_ioapic_setup;
  116. /* 1 if "noapic" boot option passed */
  117. extern int noioapicquirk;
  118. /* -1 if "noapic" boot option passed */
  119. extern int noioapicreroute;
  120. /* 1 if the timer IRQ uses the '8259A Virtual Wire' mode */
  121. extern int timer_through_8259;
  122. /*
  123. * If we use the IO-APIC for IRQ routing, disable automatic
  124. * assignment of PCI IRQ's.
  125. */
  126. #define io_apic_assign_pci_irqs \
  127. (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  128. struct io_apic_irq_attr;
  129. extern int io_apic_set_pci_routing(struct device *dev, int irq,
  130. struct io_apic_irq_attr *irq_attr);
  131. void setup_IO_APIC_irq_extra(u32 gsi);
  132. extern void ioapic_and_gsi_init(void);
  133. extern void ioapic_insert_resources(void);
  134. int io_apic_setup_irq_pin_once(unsigned int irq, int node, struct io_apic_irq_attr *attr);
  135. extern int save_ioapic_entries(void);
  136. extern void mask_ioapic_entries(void);
  137. extern int restore_ioapic_entries(void);
  138. extern int get_nr_irqs_gsi(void);
  139. extern void setup_ioapic_ids_from_mpc(void);
  140. extern void setup_ioapic_ids_from_mpc_nocheck(void);
  141. struct mp_ioapic_gsi{
  142. u32 gsi_base;
  143. u32 gsi_end;
  144. };
  145. extern struct mp_ioapic_gsi mp_gsi_routing[];
  146. extern u32 gsi_top;
  147. int mp_find_ioapic(u32 gsi);
  148. int mp_find_ioapic_pin(int ioapic, u32 gsi);
  149. void __init mp_register_ioapic(int id, u32 address, u32 gsi_base);
  150. extern void __init pre_init_apic_IRQ0(void);
  151. extern void mp_save_irq(struct mpc_intsrc *m);
  152. extern void disable_ioapic_support(void);
  153. #else /* !CONFIG_X86_IO_APIC */
  154. #define io_apic_assign_pci_irqs 0
  155. #define setup_ioapic_ids_from_mpc x86_init_noop
  156. static const int timer_through_8259 = 0;
  157. static inline void ioapic_and_gsi_init(void) { }
  158. static inline void ioapic_insert_resources(void) { }
  159. #define gsi_top (NR_IRQS_LEGACY)
  160. static inline int mp_find_ioapic(u32 gsi) { return 0; }
  161. struct io_apic_irq_attr;
  162. static inline int io_apic_set_pci_routing(struct device *dev, int irq,
  163. struct io_apic_irq_attr *irq_attr) { return 0; }
  164. static inline int save_ioapic_entries(void)
  165. {
  166. return -ENOMEM;
  167. }
  168. static inline void mask_ioapic_entries(void) { }
  169. static inline int restore_ioapic_entries(void)
  170. {
  171. return -ENOMEM;
  172. }
  173. static inline void mp_save_irq(struct mpc_intsrc *m) { };
  174. static inline void disable_ioapic_support(void) { }
  175. #endif
  176. #endif /* _ASM_X86_IO_APIC_H */