io_apic.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 IO_APIC_BASE(idx) \
  50. ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
  51. + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
  52. /*
  53. * The structure of the IO-APIC:
  54. */
  55. union IO_APIC_reg_00 {
  56. u32 raw;
  57. struct {
  58. u32 __reserved_2 : 14,
  59. LTS : 1,
  60. delivery_type : 1,
  61. __reserved_1 : 8,
  62. ID : 8;
  63. } __attribute__ ((packed)) bits;
  64. };
  65. union IO_APIC_reg_01 {
  66. u32 raw;
  67. struct {
  68. u32 version : 8,
  69. __reserved_2 : 7,
  70. PRQ : 1,
  71. entries : 8,
  72. __reserved_1 : 8;
  73. } __attribute__ ((packed)) bits;
  74. };
  75. union IO_APIC_reg_02 {
  76. u32 raw;
  77. struct {
  78. u32 __reserved_2 : 24,
  79. arbitration : 4,
  80. __reserved_1 : 4;
  81. } __attribute__ ((packed)) bits;
  82. };
  83. union IO_APIC_reg_03 {
  84. u32 raw;
  85. struct {
  86. u32 boot_DT : 1,
  87. __reserved_1 : 31;
  88. } __attribute__ ((packed)) bits;
  89. };
  90. /*
  91. * # of IO-APICs and # of IRQ routing registers
  92. */
  93. extern int nr_ioapics;
  94. extern int nr_ioapic_registers[MAX_IO_APICS];
  95. enum ioapic_irq_destination_types {
  96. dest_Fixed = 0,
  97. dest_LowestPrio = 1,
  98. dest_SMI = 2,
  99. dest__reserved_1 = 3,
  100. dest_NMI = 4,
  101. dest_INIT = 5,
  102. dest__reserved_2 = 6,
  103. dest_ExtINT = 7
  104. };
  105. struct IO_APIC_route_entry {
  106. __u32 vector : 8,
  107. delivery_mode : 3, /* 000: FIXED
  108. * 001: lowest prio
  109. * 111: ExtINT
  110. */
  111. dest_mode : 1, /* 0: physical, 1: logical */
  112. delivery_status : 1,
  113. polarity : 1,
  114. irr : 1,
  115. trigger : 1, /* 0: edge, 1: level */
  116. mask : 1, /* 0: enabled, 1: disabled */
  117. __reserved_2 : 15;
  118. union { struct { __u32
  119. __reserved_1 : 24,
  120. physical_dest : 4,
  121. __reserved_2 : 4;
  122. } physical;
  123. struct { __u32
  124. __reserved_1 : 24,
  125. logical_dest : 8;
  126. } logical;
  127. } dest;
  128. } __attribute__ ((packed));
  129. /*
  130. * MP-BIOS irq configuration table structures:
  131. */
  132. /* I/O APIC entries */
  133. extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
  134. /* # of MP IRQ source entries */
  135. extern int mp_irq_entries;
  136. /* MP IRQ source entries */
  137. extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
  138. /* non-0 if default (table-less) MP configuration */
  139. extern int mpc_default_type;
  140. static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
  141. {
  142. *IO_APIC_BASE(apic) = reg;
  143. return *(IO_APIC_BASE(apic)+4);
  144. }
  145. static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
  146. {
  147. *IO_APIC_BASE(apic) = reg;
  148. *(IO_APIC_BASE(apic)+4) = value;
  149. }
  150. /*
  151. * Re-write a value: to be used for read-modify-write
  152. * cycles where the read already set up the index register.
  153. *
  154. * Older SiS APIC requires we rewrite the index regiser
  155. */
  156. extern int sis_apic_bug;
  157. static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
  158. {
  159. if (sis_apic_bug)
  160. *IO_APIC_BASE(apic) = reg;
  161. *(IO_APIC_BASE(apic)+4) = value;
  162. }
  163. /* 1 if "noapic" boot option passed */
  164. extern int skip_ioapic_setup;
  165. /*
  166. * If we use the IO-APIC for IRQ routing, disable automatic
  167. * assignment of PCI IRQ's.
  168. */
  169. #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  170. #ifdef CONFIG_ACPI
  171. extern int io_apic_get_unique_id (int ioapic, int apic_id);
  172. extern int io_apic_get_version (int ioapic);
  173. extern int io_apic_get_redir_entries (int ioapic);
  174. extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
  175. #endif /* CONFIG_ACPI */
  176. extern int (*ioapic_renumber_irq)(int ioapic, int irq);
  177. #else /* !CONFIG_X86_IO_APIC */
  178. #define io_apic_assign_pci_irqs 0
  179. #endif
  180. extern int assign_irq_vector(int irq);
  181. #endif