io_apic.h 5.6 KB

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