io_apic.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. /*
  21. * The structure of the IO-APIC:
  22. */
  23. union IO_APIC_reg_00 {
  24. u32 raw;
  25. struct {
  26. u32 __reserved_2 : 14,
  27. LTS : 1,
  28. delivery_type : 1,
  29. __reserved_1 : 8,
  30. ID : 8;
  31. } __attribute__ ((packed)) bits;
  32. };
  33. union IO_APIC_reg_01 {
  34. u32 raw;
  35. struct {
  36. u32 version : 8,
  37. __reserved_2 : 7,
  38. PRQ : 1,
  39. entries : 8,
  40. __reserved_1 : 8;
  41. } __attribute__ ((packed)) bits;
  42. };
  43. union IO_APIC_reg_02 {
  44. u32 raw;
  45. struct {
  46. u32 __reserved_2 : 24,
  47. arbitration : 4,
  48. __reserved_1 : 4;
  49. } __attribute__ ((packed)) bits;
  50. };
  51. union IO_APIC_reg_03 {
  52. u32 raw;
  53. struct {
  54. u32 boot_DT : 1,
  55. __reserved_1 : 31;
  56. } __attribute__ ((packed)) bits;
  57. };
  58. struct IO_APIC_route_entry {
  59. __u32 vector : 8,
  60. delivery_mode : 3, /* 000: FIXED
  61. * 001: lowest prio
  62. * 111: ExtINT
  63. */
  64. dest_mode : 1, /* 0: physical, 1: logical */
  65. delivery_status : 1,
  66. polarity : 1,
  67. irr : 1,
  68. trigger : 1, /* 0: edge, 1: level */
  69. mask : 1, /* 0: enabled, 1: disabled */
  70. __reserved_2 : 15;
  71. __u32 __reserved_3 : 24,
  72. dest : 8;
  73. } __attribute__ ((packed));
  74. struct IR_IO_APIC_route_entry {
  75. __u64 vector : 8,
  76. zero : 3,
  77. index2 : 1,
  78. delivery_status : 1,
  79. polarity : 1,
  80. irr : 1,
  81. trigger : 1,
  82. mask : 1,
  83. reserved : 31,
  84. format : 1,
  85. index : 15;
  86. } __attribute__ ((packed));
  87. #define IOAPIC_AUTO -1
  88. #define IOAPIC_EDGE 0
  89. #define IOAPIC_LEVEL 1
  90. #ifdef CONFIG_X86_IO_APIC
  91. /*
  92. * # of IO-APICs and # of IRQ routing registers
  93. */
  94. extern int nr_ioapics;
  95. extern int nr_ioapic_registers[MAX_IO_APICS];
  96. #define MP_MAX_IOAPIC_PIN 127
  97. /* I/O APIC entries */
  98. extern struct mpc_ioapic mp_ioapics[MAX_IO_APICS];
  99. /* # of MP IRQ source entries */
  100. extern int mp_irq_entries;
  101. /* MP IRQ source entries */
  102. extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];
  103. /* non-0 if default (table-less) MP configuration */
  104. extern int mpc_default_type;
  105. /* Older SiS APIC requires we rewrite the index register */
  106. extern int sis_apic_bug;
  107. /* 1 if "noapic" boot option passed */
  108. extern int skip_ioapic_setup;
  109. /* 1 if "noapic" boot option passed */
  110. extern int noioapicquirk;
  111. /* -1 if "noapic" boot option passed */
  112. extern int noioapicreroute;
  113. /* 1 if the timer IRQ uses the '8259A Virtual Wire' mode */
  114. extern int timer_through_8259;
  115. /*
  116. * If we use the IO-APIC for IRQ routing, disable automatic
  117. * assignment of PCI IRQ's.
  118. */
  119. #define io_apic_assign_pci_irqs \
  120. (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  121. struct io_apic_irq_attr;
  122. extern int io_apic_set_pci_routing(struct device *dev, int irq,
  123. struct io_apic_irq_attr *irq_attr);
  124. void setup_IO_APIC_irq_extra(u32 gsi);
  125. extern void ioapic_and_gsi_init(void);
  126. extern void ioapic_insert_resources(void);
  127. int io_apic_setup_irq_pin(unsigned int irq, int node, struct io_apic_irq_attr *attr);
  128. extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
  129. extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
  130. extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
  131. extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
  132. extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
  133. extern int get_nr_irqs_gsi(void);
  134. extern void setup_ioapic_ids_from_mpc(void);
  135. extern void setup_ioapic_ids_from_mpc_nocheck(void);
  136. struct mp_ioapic_gsi{
  137. u32 gsi_base;
  138. u32 gsi_end;
  139. };
  140. extern struct mp_ioapic_gsi mp_gsi_routing[];
  141. extern u32 gsi_top;
  142. int mp_find_ioapic(u32 gsi);
  143. int mp_find_ioapic_pin(int ioapic, u32 gsi);
  144. void __init mp_register_ioapic(int id, u32 address, u32 gsi_base);
  145. extern void __init pre_init_apic_IRQ0(void);
  146. extern void mp_save_irq(struct mpc_intsrc *m);
  147. extern void disable_ioapic_support(void);
  148. #else /* !CONFIG_X86_IO_APIC */
  149. #define io_apic_assign_pci_irqs 0
  150. #define setup_ioapic_ids_from_mpc x86_init_noop
  151. static const int timer_through_8259 = 0;
  152. static inline void ioapic_and_gsi_init(void) { }
  153. static inline void ioapic_insert_resources(void) { }
  154. #define gsi_top (NR_IRQS_LEGACY)
  155. static inline int mp_find_ioapic(u32 gsi) { return 0; }
  156. struct io_apic_irq_attr;
  157. static inline int io_apic_set_pci_routing(struct device *dev, int irq,
  158. struct io_apic_irq_attr *irq_attr) { return 0; }
  159. static inline struct IO_APIC_route_entry **alloc_ioapic_entries(void)
  160. {
  161. return NULL;
  162. }
  163. static inline void free_ioapic_entries(struct IO_APIC_route_entry **ent) { }
  164. static inline int save_IO_APIC_setup(struct IO_APIC_route_entry **ent)
  165. {
  166. return -ENOMEM;
  167. }
  168. static inline void mask_IO_APIC_setup(struct IO_APIC_route_entry **ent) { }
  169. static inline int restore_IO_APIC_setup(struct IO_APIC_route_entry **ent)
  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 */