io_apic.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. #define MP_MAX_IOAPIC_PIN 127
  96. /* I/O APIC entries */
  97. extern struct mpc_ioapic mp_ioapics[MAX_IO_APICS];
  98. /* # of MP IRQ source entries */
  99. extern int mp_irq_entries;
  100. /* MP IRQ source entries */
  101. extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];
  102. /* non-0 if default (table-less) MP configuration */
  103. extern int mpc_default_type;
  104. /* Older SiS APIC requires we rewrite the index register */
  105. extern int sis_apic_bug;
  106. /* 1 if "noapic" boot option passed */
  107. extern int skip_ioapic_setup;
  108. /* 1 if "noapic" boot option passed */
  109. extern int noioapicquirk;
  110. /* -1 if "noapic" boot option passed */
  111. extern int noioapicreroute;
  112. /* 1 if the timer IRQ uses the '8259A Virtual Wire' mode */
  113. extern int timer_through_8259;
  114. /*
  115. * If we use the IO-APIC for IRQ routing, disable automatic
  116. * assignment of PCI IRQ's.
  117. */
  118. #define io_apic_assign_pci_irqs \
  119. (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  120. struct io_apic_irq_attr;
  121. extern int io_apic_set_pci_routing(struct device *dev, int irq,
  122. struct io_apic_irq_attr *irq_attr);
  123. void setup_IO_APIC_irq_extra(u32 gsi);
  124. extern void ioapic_and_gsi_init(void);
  125. extern void ioapic_insert_resources(void);
  126. int io_apic_setup_irq_pin_once(unsigned int irq, int node, struct io_apic_irq_attr *attr);
  127. extern int save_ioapic_entries(void);
  128. extern void mask_ioapic_entries(void);
  129. extern int restore_ioapic_entries(void);
  130. extern int get_nr_irqs_gsi(void);
  131. extern void setup_ioapic_ids_from_mpc(void);
  132. extern void setup_ioapic_ids_from_mpc_nocheck(void);
  133. struct mp_ioapic_gsi{
  134. u32 gsi_base;
  135. u32 gsi_end;
  136. };
  137. extern struct mp_ioapic_gsi mp_gsi_routing[];
  138. extern u32 gsi_top;
  139. int mp_find_ioapic(u32 gsi);
  140. int mp_find_ioapic_pin(int ioapic, u32 gsi);
  141. void __init mp_register_ioapic(int id, u32 address, u32 gsi_base);
  142. extern void __init pre_init_apic_IRQ0(void);
  143. extern void mp_save_irq(struct mpc_intsrc *m);
  144. extern void disable_ioapic_support(void);
  145. #else /* !CONFIG_X86_IO_APIC */
  146. #define io_apic_assign_pci_irqs 0
  147. #define setup_ioapic_ids_from_mpc x86_init_noop
  148. static const int timer_through_8259 = 0;
  149. static inline void ioapic_and_gsi_init(void) { }
  150. static inline void ioapic_insert_resources(void) { }
  151. #define gsi_top (NR_IRQS_LEGACY)
  152. static inline int mp_find_ioapic(u32 gsi) { return 0; }
  153. struct io_apic_irq_attr;
  154. static inline int io_apic_set_pci_routing(struct device *dev, int irq,
  155. struct io_apic_irq_attr *irq_attr) { return 0; }
  156. static inline int save_ioapic_entries(void)
  157. {
  158. return -ENOMEM;
  159. }
  160. static inline void mask_ioapic_entries(void) { }
  161. static inline int restore_ioapic_entries(void)
  162. {
  163. return -ENOMEM;
  164. }
  165. static inline void mp_save_irq(struct mpc_intsrc *m) { };
  166. static inline void disable_ioapic_support(void) { }
  167. #endif
  168. #endif /* _ASM_X86_IO_APIC_H */