io_apic.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #ifndef __ASM_IO_APIC_H
  2. #define __ASM_IO_APIC_H
  3. #include <asm/types.h>
  4. #include <asm/mpspec.h>
  5. /*
  6. * Intel IO-APIC support for SMP and UP systems.
  7. *
  8. * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
  9. */
  10. #ifdef CONFIG_X86_IO_APIC
  11. #ifdef CONFIG_PCI_MSI
  12. static inline int use_pci_vector(void) {return 1;}
  13. static inline void disable_edge_ioapic_vector(unsigned int vector) { }
  14. static inline void mask_and_ack_level_ioapic_vector(unsigned int vector) { }
  15. static inline void end_edge_ioapic_vector (unsigned int vector) { }
  16. #define startup_level_ioapic startup_level_ioapic_vector
  17. #define shutdown_level_ioapic mask_IO_APIC_vector
  18. #define enable_level_ioapic unmask_IO_APIC_vector
  19. #define disable_level_ioapic mask_IO_APIC_vector
  20. #define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_vector
  21. #define end_level_ioapic end_level_ioapic_vector
  22. #define set_ioapic_affinity set_ioapic_affinity_vector
  23. #define startup_edge_ioapic startup_edge_ioapic_vector
  24. #define shutdown_edge_ioapic disable_edge_ioapic_vector
  25. #define enable_edge_ioapic unmask_IO_APIC_vector
  26. #define disable_edge_ioapic disable_edge_ioapic_vector
  27. #define ack_edge_ioapic ack_edge_ioapic_vector
  28. #define end_edge_ioapic end_edge_ioapic_vector
  29. #else
  30. static inline int use_pci_vector(void) {return 0;}
  31. static inline void disable_edge_ioapic_irq(unsigned int irq) { }
  32. static inline void mask_and_ack_level_ioapic_irq(unsigned int irq) { }
  33. static inline void end_edge_ioapic_irq (unsigned int irq) { }
  34. #define startup_level_ioapic startup_level_ioapic_irq
  35. #define shutdown_level_ioapic mask_IO_APIC_irq
  36. #define enable_level_ioapic unmask_IO_APIC_irq
  37. #define disable_level_ioapic mask_IO_APIC_irq
  38. #define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_irq
  39. #define end_level_ioapic end_level_ioapic_irq
  40. #define set_ioapic_affinity set_ioapic_affinity_irq
  41. #define startup_edge_ioapic startup_edge_ioapic_irq
  42. #define shutdown_edge_ioapic disable_edge_ioapic_irq
  43. #define enable_edge_ioapic unmask_IO_APIC_irq
  44. #define disable_edge_ioapic disable_edge_ioapic_irq
  45. #define ack_edge_ioapic ack_edge_ioapic_irq
  46. #define end_edge_ioapic end_edge_ioapic_irq
  47. #endif
  48. #define IO_APIC_BASE(idx) \
  49. ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
  50. + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
  51. /*
  52. * The structure of the IO-APIC:
  53. */
  54. union IO_APIC_reg_00 {
  55. u32 raw;
  56. struct {
  57. u32 __reserved_2 : 14,
  58. LTS : 1,
  59. delivery_type : 1,
  60. __reserved_1 : 8,
  61. ID : 8;
  62. } __attribute__ ((packed)) bits;
  63. };
  64. union IO_APIC_reg_01 {
  65. u32 raw;
  66. struct {
  67. u32 version : 8,
  68. __reserved_2 : 7,
  69. PRQ : 1,
  70. entries : 8,
  71. __reserved_1 : 8;
  72. } __attribute__ ((packed)) bits;
  73. };
  74. union IO_APIC_reg_02 {
  75. u32 raw;
  76. struct {
  77. u32 __reserved_2 : 24,
  78. arbitration : 4,
  79. __reserved_1 : 4;
  80. } __attribute__ ((packed)) bits;
  81. };
  82. union IO_APIC_reg_03 {
  83. u32 raw;
  84. struct {
  85. u32 boot_DT : 1,
  86. __reserved_1 : 31;
  87. } __attribute__ ((packed)) bits;
  88. };
  89. /*
  90. * # of IO-APICs and # of IRQ routing registers
  91. */
  92. extern int nr_ioapics;
  93. extern int nr_ioapic_registers[MAX_IO_APICS];
  94. enum ioapic_irq_destination_types {
  95. dest_Fixed = 0,
  96. dest_LowestPrio = 1,
  97. dest_SMI = 2,
  98. dest__reserved_1 = 3,
  99. dest_NMI = 4,
  100. dest_INIT = 5,
  101. dest__reserved_2 = 6,
  102. dest_ExtINT = 7
  103. };
  104. struct IO_APIC_route_entry {
  105. __u32 vector : 8,
  106. delivery_mode : 3, /* 000: FIXED
  107. * 001: lowest prio
  108. * 111: ExtINT
  109. */
  110. dest_mode : 1, /* 0: physical, 1: logical */
  111. delivery_status : 1,
  112. polarity : 1,
  113. irr : 1,
  114. trigger : 1, /* 0: edge, 1: level */
  115. mask : 1, /* 0: enabled, 1: disabled */
  116. __reserved_2 : 15;
  117. union { struct { __u32
  118. __reserved_1 : 24,
  119. physical_dest : 4,
  120. __reserved_2 : 4;
  121. } physical;
  122. struct { __u32
  123. __reserved_1 : 24,
  124. logical_dest : 8;
  125. } logical;
  126. } dest;
  127. } __attribute__ ((packed));
  128. /*
  129. * MP-BIOS irq configuration table structures:
  130. */
  131. /* I/O APIC entries */
  132. extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
  133. /* # of MP IRQ source entries */
  134. extern int mp_irq_entries;
  135. /* MP IRQ source entries */
  136. extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
  137. /* non-0 if default (table-less) MP configuration */
  138. extern int mpc_default_type;
  139. static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
  140. {
  141. *IO_APIC_BASE(apic) = reg;
  142. return *(IO_APIC_BASE(apic)+4);
  143. }
  144. static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
  145. {
  146. *IO_APIC_BASE(apic) = reg;
  147. *(IO_APIC_BASE(apic)+4) = value;
  148. }
  149. /*
  150. * Re-write a value: to be used for read-modify-write
  151. * cycles where the read already set up the index register.
  152. *
  153. * Older SiS APIC requires we rewrite the index regiser
  154. */
  155. extern int sis_apic_bug;
  156. static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
  157. {
  158. if (sis_apic_bug)
  159. *IO_APIC_BASE(apic) = reg;
  160. *(IO_APIC_BASE(apic)+4) = value;
  161. }
  162. /* 1 if "noapic" boot option passed */
  163. extern int skip_ioapic_setup;
  164. static inline void disable_ioapic_setup(void)
  165. {
  166. skip_ioapic_setup = 1;
  167. }
  168. static inline int ioapic_setup_disabled(void)
  169. {
  170. return skip_ioapic_setup;
  171. }
  172. /*
  173. * If we use the IO-APIC for IRQ routing, disable automatic
  174. * assignment of PCI IRQ's.
  175. */
  176. #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  177. #ifdef CONFIG_ACPI
  178. extern int io_apic_get_unique_id (int ioapic, int apic_id);
  179. extern int io_apic_get_version (int ioapic);
  180. extern int io_apic_get_redir_entries (int ioapic);
  181. extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
  182. extern int timer_uses_ioapic_pin_0;
  183. #endif /* CONFIG_ACPI */
  184. extern int (*ioapic_renumber_irq)(int ioapic, int irq);
  185. #else /* !CONFIG_X86_IO_APIC */
  186. #define io_apic_assign_pci_irqs 0
  187. static inline void disable_ioapic_setup(void) { }
  188. #endif
  189. extern int assign_irq_vector(int irq);
  190. #endif