io_apic.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_IO_APIC_H
  3. #define _ASM_X86_IO_APIC_H
  4. #include <linux/types.h>
  5. #include <asm/mpspec.h>
  6. #include <asm/apicdef.h>
  7. #include <asm/irq_vectors.h>
  8. #include <asm/x86_init.h>
  9. /*
  10. * Intel IO-APIC support for SMP and UP systems.
  11. *
  12. * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
  13. */
  14. /*
  15. * The structure of the IO-APIC:
  16. */
  17. union IO_APIC_reg_00 {
  18. u32 raw;
  19. struct {
  20. u32 __reserved_2 : 14,
  21. LTS : 1,
  22. delivery_type : 1,
  23. __reserved_1 : 8,
  24. ID : 8;
  25. } __attribute__ ((packed)) bits;
  26. };
  27. union IO_APIC_reg_01 {
  28. u32 raw;
  29. struct {
  30. u32 version : 8,
  31. __reserved_2 : 7,
  32. PRQ : 1,
  33. entries : 8,
  34. __reserved_1 : 8;
  35. } __attribute__ ((packed)) bits;
  36. };
  37. union IO_APIC_reg_02 {
  38. u32 raw;
  39. struct {
  40. u32 __reserved_2 : 24,
  41. arbitration : 4,
  42. __reserved_1 : 4;
  43. } __attribute__ ((packed)) bits;
  44. };
  45. union IO_APIC_reg_03 {
  46. u32 raw;
  47. struct {
  48. u32 boot_DT : 1,
  49. __reserved_1 : 31;
  50. } __attribute__ ((packed)) bits;
  51. };
  52. struct IO_APIC_route_entry {
  53. union {
  54. struct {
  55. u64 vector : 8,
  56. delivery_mode : 3,
  57. dest_mode_logical : 1,
  58. delivery_status : 1,
  59. active_low : 1,
  60. irr : 1,
  61. is_level : 1,
  62. masked : 1,
  63. reserved_0 : 15,
  64. reserved_1 : 17,
  65. virt_destid_8_14 : 7,
  66. destid_0_7 : 8;
  67. };
  68. struct {
  69. u64 ir_shared_0 : 8,
  70. ir_zero : 3,
  71. ir_index_15 : 1,
  72. ir_shared_1 : 5,
  73. ir_reserved_0 : 31,
  74. ir_format : 1,
  75. ir_index_0_14 : 15;
  76. };
  77. struct {
  78. u64 w1 : 32,
  79. w2 : 32;
  80. };
  81. };
  82. } __attribute__ ((packed));
  83. struct irq_alloc_info;
  84. struct ioapic_domain_cfg;
  85. #define IOAPIC_MAP_ALLOC 0x1
  86. #define IOAPIC_MAP_CHECK 0x2
  87. #ifdef CONFIG_X86_IO_APIC
  88. /*
  89. * # of IO-APICs and # of IRQ routing registers
  90. */
  91. extern int nr_ioapics;
  92. extern int mpc_ioapic_id(int ioapic);
  93. extern unsigned int mpc_ioapic_addr(int ioapic);
  94. /* # of MP IRQ source entries */
  95. extern int mp_irq_entries;
  96. /* MP IRQ source entries */
  97. extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];
  98. /* 1 if "noapic" boot option passed */
  99. extern int skip_ioapic_setup;
  100. /* 1 if "noapic" boot option passed */
  101. extern int noioapicquirk;
  102. /* -1 if "noapic" boot option passed */
  103. extern int noioapicreroute;
  104. extern u32 gsi_top;
  105. extern unsigned long io_apic_irqs;
  106. #define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1 << (x)) & io_apic_irqs))
  107. /*
  108. * If we use the IO-APIC for IRQ routing, disable automatic
  109. * assignment of PCI IRQ's.
  110. */
  111. #define io_apic_assign_pci_irqs \
  112. (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  113. struct irq_cfg;
  114. extern void ioapic_insert_resources(void);
  115. extern int arch_early_ioapic_init(void);
  116. extern int save_ioapic_entries(void);
  117. extern void mask_ioapic_entries(void);
  118. extern int restore_ioapic_entries(void);
  119. extern void setup_ioapic_ids_from_mpc(void);
  120. extern void setup_ioapic_ids_from_mpc_nocheck(void);
  121. extern int mp_find_ioapic(u32 gsi);
  122. extern int mp_find_ioapic_pin(int ioapic, u32 gsi);
  123. extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
  124. struct irq_alloc_info *info);
  125. extern void mp_unmap_irq(int irq);
  126. extern int mp_register_ioapic(int id, u32 address, u32 gsi_base,
  127. struct ioapic_domain_cfg *cfg);
  128. extern int mp_unregister_ioapic(u32 gsi_base);
  129. extern int mp_ioapic_registered(u32 gsi_base);
  130. extern void ioapic_set_alloc_attr(struct irq_alloc_info *info,
  131. int node, int trigger, int polarity);
  132. extern void mp_save_irq(struct mpc_intsrc *m);
  133. extern void disable_ioapic_support(void);
  134. extern void __init io_apic_init_mappings(void);
  135. extern unsigned int native_io_apic_read(unsigned int apic, unsigned int reg);
  136. extern void native_restore_boot_irq_mode(void);
  137. static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
  138. {
  139. return x86_apic_ops.io_apic_read(apic, reg);
  140. }
  141. extern void setup_IO_APIC(void);
  142. extern void enable_IO_APIC(void);
  143. extern void clear_IO_APIC(void);
  144. extern void restore_boot_irq_mode(void);
  145. extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin);
  146. extern void print_IO_APICs(void);
  147. #else /* !CONFIG_X86_IO_APIC */
  148. #define IO_APIC_IRQ(x) 0
  149. #define io_apic_assign_pci_irqs 0
  150. #define setup_ioapic_ids_from_mpc x86_init_noop
  151. static inline void ioapic_insert_resources(void) { }
  152. static inline int arch_early_ioapic_init(void) { return 0; }
  153. static inline void print_IO_APICs(void) {}
  154. #define gsi_top (NR_IRQS_LEGACY)
  155. static inline int mp_find_ioapic(u32 gsi) { return 0; }
  156. static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
  157. struct irq_alloc_info *info)
  158. {
  159. return gsi;
  160. }
  161. static inline void mp_unmap_irq(int irq) { }
  162. static inline int save_ioapic_entries(void)
  163. {
  164. return -ENOMEM;
  165. }
  166. static inline void mask_ioapic_entries(void) { }
  167. static inline int restore_ioapic_entries(void)
  168. {
  169. return -ENOMEM;
  170. }
  171. static inline void mp_save_irq(struct mpc_intsrc *m) { }
  172. static inline void disable_ioapic_support(void) { }
  173. static inline void io_apic_init_mappings(void) { }
  174. #define native_io_apic_read NULL
  175. #define native_restore_boot_irq_mode NULL
  176. static inline void setup_IO_APIC(void) { }
  177. static inline void enable_IO_APIC(void) { }
  178. static inline void restore_boot_irq_mode(void) { }
  179. #endif
  180. #endif /* _ASM_X86_IO_APIC_H */