1 /* Copyright 2003 Andi Kleen, SuSE Labs.
2 * Subject to the GNU Public License, v.2
4 * Generic x86 APIC driver probe layer.
6 #include <linux/threads.h>
7 #include <linux/cpumask.h>
8 #include <linux/string.h>
9 #include <linux/kernel.h>
10 #include <linux/ctype.h>
11 #include <linux/init.h>
12 #include <asm/fixmap.h>
13 #include <asm/mpspec.h>
14 #include <asm/apicdef.h>
15 #include <asm/genapic.h>
17 extern struct genapic apic_summit;
18 extern struct genapic apic_bigsmp;
19 extern struct genapic apic_es7000;
20 extern struct genapic apic_default;
22 struct genapic *genapic = &apic_default;
24 struct genapic *apic_probe[] __initdata = {
28 &apic_default, /* must be last */
32 static int cmdline_apic;
34 void __init generic_bigsmp_probe(void)
37 * This routine is used to switch to bigsmp mode when
38 * - There is no apic= option specified by the user
39 * - generic_apic_probe() has choosen apic_default as the sub_arch
40 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
43 if (!cmdline_apic && genapic == &apic_default)
44 if (apic_bigsmp.probe()) {
45 genapic = &apic_bigsmp;
46 printk(KERN_INFO "Overriding APIC driver with %s\n",
51 void __init generic_apic_probe(char *command_line)
57 s = strstr(command_line, "apic=");
58 if (s && (s == command_line || isspace(s[-1]))) {
59 char *p = strchr(s, ' '), old;
64 for (i = 0; !changed && apic_probe[i]; i++) {
65 if (!strcmp(apic_probe[i]->name, s+5)) {
67 genapic = apic_probe[i];
71 printk(KERN_ERR "Unknown genapic `%s' specified.\n", s);
73 cmdline_apic = changed;
75 for (i = 0; !changed && apic_probe[i]; i++) {
76 if (apic_probe[i]->probe()) {
78 genapic = apic_probe[i];
81 /* Not visible without early console */
83 panic("Didn't find an APIC driver");
85 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
88 /* These functions can switch the APIC even after the initial ->probe() */
90 int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
93 for (i = 0; apic_probe[i]; ++i) {
94 if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
96 genapic = apic_probe[i];
97 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
106 int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
109 for (i = 0; apic_probe[i]; ++i) {
110 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
112 genapic = apic_probe[i];
113 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
122 int hard_smp_processor_id(void)
124 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));