io_apic.h 5.5 KB

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