2 * Copyright 2003 Andi Kleen, SuSE Labs.
3 * Subject to the GNU Public License, v.2
5 * Generic x86 APIC driver probe layer.
7 #include <linux/threads.h>
8 #include <linux/cpumask.h>
9 #include <linux/string.h>
10 #include <linux/kernel.h>
11 #include <linux/ctype.h>
12 #include <linux/init.h>
13 #include <linux/errno.h>
14 #include <asm/fixmap.h>
15 #include <asm/mpspec.h>
16 #include <asm/apicdef.h>
17 #include <asm/genapic.h>
18 #include <asm/setup.h>
20 extern struct genapic apic_numaq;
21 extern struct genapic apic_summit;
22 extern struct genapic apic_bigsmp;
23 extern struct genapic apic_es7000;
24 extern struct genapic apic_default;
26 struct genapic *genapic = &apic_default;
28 static struct genapic *apic_probe[] __initdata = {
29 #ifdef CONFIG_X86_NUMAQ
32 #ifdef CONFIG_X86_SUMMIT
35 #ifdef CONFIG_X86_BIGSMP
38 #ifdef CONFIG_X86_ES7000
41 &apic_default, /* must be last */
45 static int cmdline_apic __initdata;
46 static int __init parse_apic(char *arg)
53 for (i = 0; apic_probe[i]; i++) {
54 if (!strcmp(apic_probe[i]->name, arg)) {
55 genapic = apic_probe[i];
61 if (x86_quirks->update_genapic)
62 x86_quirks->update_genapic();
64 /* Parsed again by __setup for debug/verbose */
67 early_param("apic", parse_apic);
69 void __init generic_bigsmp_probe(void)
71 #ifdef CONFIG_X86_BIGSMP
73 * This routine is used to switch to bigsmp mode when
74 * - There is no apic= option specified by the user
75 * - generic_apic_probe() has chosen apic_default as the sub_arch
76 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
79 if (!cmdline_apic && genapic == &apic_default) {
80 if (apic_bigsmp.probe()) {
81 genapic = &apic_bigsmp;
82 if (x86_quirks->update_genapic)
83 x86_quirks->update_genapic();
84 printk(KERN_INFO "Overriding APIC driver with %s\n",
91 void __init generic_apic_probe(void)
95 for (i = 0; apic_probe[i]; i++) {
96 if (apic_probe[i]->probe()) {
97 genapic = apic_probe[i];
101 /* Not visible without early console */
103 panic("Didn't find an APIC driver");
105 if (x86_quirks->update_genapic)
106 x86_quirks->update_genapic();
108 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
111 /* These functions can switch the APIC even after the initial ->probe() */
113 int __init mps_oem_check(struct mp_config_table *mpc, char *oem,
117 for (i = 0; apic_probe[i]; ++i) {
118 if (apic_probe[i]->mps_oem_check(mpc, oem, productid)) {
120 genapic = apic_probe[i];
121 if (x86_quirks->update_genapic)
122 x86_quirks->update_genapic();
123 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
132 int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
135 for (i = 0; apic_probe[i]; ++i) {
136 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
138 genapic = apic_probe[i];
139 if (x86_quirks->update_genapic)
140 x86_quirks->update_genapic();
141 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
150 int hard_smp_processor_id(void)
152 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));