2 * Default generic APIC driver. This handles up to 8 CPUs.
4 * Copyright 2003 Andi Kleen, SuSE Labs.
5 * Subject to the GNU Public License, v.2
7 * Generic x86 APIC driver probe layer.
9 #include <linux/threads.h>
10 #include <linux/cpumask.h>
11 #include <linux/string.h>
12 #include <linux/kernel.h>
13 #include <linux/ctype.h>
14 #include <linux/init.h>
15 #include <linux/errno.h>
16 #include <asm/fixmap.h>
17 #include <asm/mpspec.h>
18 #include <asm/apicdef.h>
19 #include <asm/genapic.h>
20 #include <asm/setup.h>
22 #include <linux/threads.h>
23 #include <linux/cpumask.h>
24 #include <asm/mpspec.h>
25 #include <asm/genapic.h>
26 #include <asm/fixmap.h>
27 #include <asm/apicdef.h>
28 #include <linux/kernel.h>
29 #include <linux/string.h>
30 #include <linux/smp.h>
31 #include <linux/init.h>
32 #include <asm/genapic.h>
35 #include <linux/smp.h>
36 #include <linux/init.h>
37 #include <linux/interrupt.h>
39 #include <asm/arch_hooks.h>
41 #include <asm/setup.h>
43 #include <asm/genapic.h>
45 #ifdef CONFIG_HOTPLUG_CPU
46 #define DEFAULT_SEND_IPI (1)
48 #define DEFAULT_SEND_IPI (0)
51 int no_broadcast = DEFAULT_SEND_IPI;
53 #ifdef CONFIG_X86_LOCAL_APIC
55 static void default_vector_allocation_domain(int cpu, struct cpumask *retmask)
58 * Careful. Some cpus do not strictly honor the set of cpus
59 * specified in the interrupt destination when using lowest
60 * priority interrupt delivery mode.
62 * In particular there was a hyperthreading cpu observed to
63 * deliver interrupts to the wrong hyperthread when only one
64 * hyperthread was specified in the interrupt desitination.
66 *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };
69 /* should be called last. */
70 static int probe_default(void)
75 struct genapic apic_default = {
78 .probe = probe_default,
79 .acpi_madt_oem_check = NULL,
80 .apic_id_registered = default_apic_id_registered,
82 .irq_delivery_mode = dest_LowestPrio,
83 /* logical delivery broadcast to all CPUs: */
86 .target_cpus = default_target_cpus,
88 .dest_logical = APIC_DEST_LOGICAL,
89 .check_apicid_used = default_check_apicid_used,
90 .check_apicid_present = default_check_apicid_present,
92 .vector_allocation_domain = default_vector_allocation_domain,
93 .init_apic_ldr = default_init_apic_ldr,
95 .ioapic_phys_id_map = default_ioapic_phys_id_map,
96 .setup_apic_routing = default_setup_apic_routing,
97 .multi_timer_check = NULL,
98 .apicid_to_node = default_apicid_to_node,
99 .cpu_to_logical_apicid = default_cpu_to_logical_apicid,
100 .cpu_present_to_apicid = default_cpu_present_to_apicid,
101 .apicid_to_cpu_present = default_apicid_to_cpu_present,
102 .setup_portio_remap = NULL,
103 .check_phys_apicid_present = default_check_phys_apicid_present,
104 .enable_apic_mode = NULL,
105 .phys_pkg_id = default_phys_pkg_id,
106 .mps_oem_check = NULL,
108 .get_apic_id = default_get_apic_id,
110 .apic_id_mask = 0x0F << 24,
112 .cpu_mask_to_apicid = default_cpu_mask_to_apicid,
113 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
115 .send_IPI_mask = default_send_IPI_mask,
116 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself,
117 .send_IPI_allbutself = default_send_IPI_allbutself,
118 .send_IPI_all = default_send_IPI_all,
119 .send_IPI_self = NULL,
122 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
123 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
125 .wait_for_init_deassert = default_wait_for_init_deassert,
127 .smp_callin_clear_local_apic = NULL,
128 .store_NMI_vector = NULL,
129 .inquire_remote_apic = default_inquire_remote_apic,
132 extern struct genapic apic_numaq;
133 extern struct genapic apic_summit;
134 extern struct genapic apic_bigsmp;
135 extern struct genapic apic_es7000;
136 extern struct genapic apic_default;
138 struct genapic *apic = &apic_default;
140 static struct genapic *apic_probe[] __initdata = {
141 #ifdef CONFIG_X86_NUMAQ
144 #ifdef CONFIG_X86_SUMMIT
147 #ifdef CONFIG_X86_BIGSMP
150 #ifdef CONFIG_X86_ES7000
153 &apic_default, /* must be last */
157 static int cmdline_apic __initdata;
158 static int __init parse_apic(char *arg)
165 for (i = 0; apic_probe[i]; i++) {
166 if (!strcmp(apic_probe[i]->name, arg)) {
167 apic = apic_probe[i];
173 if (x86_quirks->update_genapic)
174 x86_quirks->update_genapic();
176 /* Parsed again by __setup for debug/verbose */
179 early_param("apic", parse_apic);
181 void __init generic_bigsmp_probe(void)
183 #ifdef CONFIG_X86_BIGSMP
185 * This routine is used to switch to bigsmp mode when
186 * - There is no apic= option specified by the user
187 * - generic_apic_probe() has chosen apic_default as the sub_arch
188 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
191 if (!cmdline_apic && apic == &apic_default) {
192 if (apic_bigsmp.probe()) {
194 if (x86_quirks->update_genapic)
195 x86_quirks->update_genapic();
196 printk(KERN_INFO "Overriding APIC driver with %s\n",
203 void __init generic_apic_probe(void)
207 for (i = 0; apic_probe[i]; i++) {
208 if (apic_probe[i]->probe()) {
209 apic = apic_probe[i];
213 /* Not visible without early console */
215 panic("Didn't find an APIC driver");
217 if (x86_quirks->update_genapic)
218 x86_quirks->update_genapic();
220 printk(KERN_INFO "Using APIC driver %s\n", apic->name);
223 /* These functions can switch the APIC even after the initial ->probe() */
226 generic_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
230 for (i = 0; apic_probe[i]; ++i) {
231 if (!apic_probe[i]->mps_oem_check)
233 if (!apic_probe[i]->mps_oem_check(mpc, oem, productid))
237 apic = apic_probe[i];
238 if (x86_quirks->update_genapic)
239 x86_quirks->update_genapic();
240 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
248 int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
252 for (i = 0; apic_probe[i]; ++i) {
253 if (!apic_probe[i]->acpi_madt_oem_check)
255 if (!apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id))
259 apic = apic_probe[i];
260 if (x86_quirks->update_genapic)
261 x86_quirks->update_genapic();
262 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
270 #endif /* CONFIG_X86_LOCAL_APIC */
273 * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
276 * Perform any necessary interrupt initialisation prior to setting up
277 * the "ordinary" interrupt call gates. For legacy reasons, the ISA
278 * interrupts should be initialised here if the machine emulates a PC
281 void __init pre_intr_init_hook(void)
283 if (x86_quirks->arch_pre_intr_init) {
284 if (x86_quirks->arch_pre_intr_init())
291 * intr_init_hook - post gate setup interrupt initialisation
294 * Fill in any interrupts that may have been left out by the general
295 * init_IRQ() routine. interrupts having to do with the machine rather
296 * than the devices on the I/O bus (like APIC interrupts in intel MP
297 * systems) are started here.
299 void __init intr_init_hook(void)
301 if (x86_quirks->arch_intr_init) {
302 if (x86_quirks->arch_intr_init())
308 * pre_setup_arch_hook - hook called prior to any setup_arch() execution
311 * generally used to activate any machine specific identification
312 * routines that may be needed before setup_arch() runs. On Voyager
313 * this is used to get the board revision and type.
315 void __init pre_setup_arch_hook(void)
320 * trap_init_hook - initialise system specific traps
323 * Called as the final act of trap_init(). Used in VISWS to initialise
324 * the various board specific APIC traps.
326 void __init trap_init_hook(void)
328 if (x86_quirks->arch_trap_init) {
329 if (x86_quirks->arch_trap_init())
334 static struct irqaction irq0 = {
335 .handler = timer_interrupt,
336 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL,
337 .mask = CPU_MASK_NONE,
342 * pre_time_init_hook - do any specific initialisations before.
345 void __init pre_time_init_hook(void)
347 if (x86_quirks->arch_pre_time_init)
348 x86_quirks->arch_pre_time_init();
352 * time_init_hook - do any specific initialisations for the system timer.
355 * Must plug the system timer interrupt source at HZ into the IRQ listed
356 * in irq_vectors.h:TIMER_IRQ
358 void __init time_init_hook(void)
360 if (x86_quirks->arch_time_init) {
362 * A nonzero return code does not mean failure, it means
363 * that the architecture quirk does not want any
364 * generic (timer) setup to be performed after this:
366 if (x86_quirks->arch_time_init())
370 irq0.mask = cpumask_of_cpu(0);
376 * mca_nmi_hook - hook into MCA specific NMI chain
379 * The MCA (Microchannel Architecture) has an NMI chain for NMI sources
380 * along the MCA bus. Use this to hook into that chain if you will need
383 void mca_nmi_hook(void)
386 * If I recall correctly, there's a whole bunch of other things that
387 * we can do to check for NMI problems, but that's all I know about
390 pr_warning("NMI generated from unknown source!\n");
394 static __init int no_ipi_broadcast(char *str)
396 get_option(&str, &no_broadcast);
397 pr_info("Using %s mode\n",
398 no_broadcast ? "No IPI Broadcast" : "IPI Broadcast");
401 __setup("no_ipi_broadcast=", no_ipi_broadcast);
403 static int __init print_ipi_mode(void)
405 pr_info("Using IPI %s mode\n",
406 no_broadcast ? "No-Shortcut" : "Shortcut");
410 late_initcall(print_ipi_mode);