1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_IO_APIC_H
3 #define _ASM_X86_IO_APIC_H
5 #include <linux/types.h>
6 #include <asm/mpspec.h>
7 #include <asm/apicdef.h>
8 #include <asm/irq_vectors.h>
9 #include <asm/x86_init.h>
11 * Intel IO-APIC support for SMP and UP systems.
13 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
17 * The structure of the IO-APIC:
19 union IO_APIC_reg_00 {
22 u32 __reserved_2 : 14,
27 } __attribute__ ((packed)) bits;
30 union IO_APIC_reg_01 {
38 } __attribute__ ((packed)) bits;
41 union IO_APIC_reg_02 {
44 u32 __reserved_2 : 24,
47 } __attribute__ ((packed)) bits;
50 union IO_APIC_reg_03 {
55 } __attribute__ ((packed)) bits;
58 struct IO_APIC_route_entry {
63 dest_mode_logical : 1,
88 } __attribute__ ((packed));
90 struct irq_alloc_info;
91 struct ioapic_domain_cfg;
93 #define IOAPIC_MAP_ALLOC 0x1
94 #define IOAPIC_MAP_CHECK 0x2
96 #ifdef CONFIG_X86_IO_APIC
99 * # of IO-APICs and # of IRQ routing registers
101 extern int nr_ioapics;
103 extern int mpc_ioapic_id(int ioapic);
104 extern unsigned int mpc_ioapic_addr(int ioapic);
106 /* # of MP IRQ source entries */
107 extern int mp_irq_entries;
109 /* MP IRQ source entries */
110 extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES];
112 /* True if "noapic" boot option passed */
113 extern bool ioapic_is_disabled;
115 /* 1 if "noapic" boot option passed */
116 extern int noioapicquirk;
118 /* -1 if "noapic" boot option passed */
119 extern int noioapicreroute;
123 extern unsigned long io_apic_irqs;
125 #define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1 << (x)) & io_apic_irqs))
128 * If we use the IO-APIC for IRQ routing, disable automatic
129 * assignment of PCI IRQ's.
131 #define io_apic_assign_pci_irqs \
132 (mp_irq_entries && !ioapic_is_disabled && io_apic_irqs)
135 extern void ioapic_insert_resources(void);
136 extern int arch_early_ioapic_init(void);
138 extern int save_ioapic_entries(void);
139 extern void mask_ioapic_entries(void);
140 extern int restore_ioapic_entries(void);
142 extern void setup_ioapic_ids_from_mpc(void);
143 extern void setup_ioapic_ids_from_mpc_nocheck(void);
145 extern int mp_find_ioapic(u32 gsi);
146 extern int mp_find_ioapic_pin(int ioapic, u32 gsi);
147 extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
148 struct irq_alloc_info *info);
149 extern void mp_unmap_irq(int irq);
150 extern int mp_register_ioapic(int id, u32 address, u32 gsi_base,
151 struct ioapic_domain_cfg *cfg);
152 extern int mp_unregister_ioapic(u32 gsi_base);
153 extern int mp_ioapic_registered(u32 gsi_base);
155 extern void ioapic_set_alloc_attr(struct irq_alloc_info *info,
156 int node, int trigger, int polarity);
158 extern void mp_save_irq(struct mpc_intsrc *m);
160 extern void disable_ioapic_support(void);
162 extern void __init io_apic_init_mappings(void);
163 extern unsigned int native_io_apic_read(unsigned int apic, unsigned int reg);
164 extern void native_restore_boot_irq_mode(void);
166 static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
168 return x86_apic_ops.io_apic_read(apic, reg);
171 extern void setup_IO_APIC(void);
172 extern void enable_IO_APIC(void);
173 extern void clear_IO_APIC(void);
174 extern void restore_boot_irq_mode(void);
175 extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin);
176 extern void print_IO_APICs(void);
177 #else /* !CONFIG_X86_IO_APIC */
179 #define IO_APIC_IRQ(x) 0
180 #define io_apic_assign_pci_irqs 0
181 #define setup_ioapic_ids_from_mpc x86_init_noop
182 #define nr_ioapics (0)
183 static inline void ioapic_insert_resources(void) { }
184 static inline int arch_early_ioapic_init(void) { return 0; }
185 static inline void print_IO_APICs(void) {}
186 #define gsi_top (NR_IRQS_LEGACY)
187 static inline int mp_find_ioapic(u32 gsi) { return 0; }
188 static inline int mp_map_gsi_to_irq(u32 gsi, unsigned int flags,
189 struct irq_alloc_info *info)
194 static inline void mp_unmap_irq(int irq) { }
196 static inline int save_ioapic_entries(void)
201 static inline void mask_ioapic_entries(void) { }
202 static inline int restore_ioapic_entries(void)
207 static inline void mp_save_irq(struct mpc_intsrc *m) { }
208 static inline void disable_ioapic_support(void) { }
209 static inline void io_apic_init_mappings(void) { }
210 #define native_io_apic_read NULL
211 #define native_restore_boot_irq_mode NULL
213 static inline void setup_IO_APIC(void) { }
214 static inline void enable_IO_APIC(void) { }
215 static inline void restore_boot_irq_mode(void) { }
219 #endif /* _ASM_X86_IO_APIC_H */