blob: bcd1bcfaa7238e9ad546c7191d506e0329e8f578 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* Copyright 2003 Andi Kleen, SuSE Labs.
2 * Subject to the GNU Public License, v.2
3 *
4 * Generic x86 APIC driver probe layer.
5 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#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>
16
17extern struct genapic apic_summit;
18extern struct genapic apic_bigsmp;
19extern struct genapic apic_es7000;
20extern struct genapic apic_default;
21
22struct genapic *genapic = &apic_default;
23
24struct genapic *apic_probe[] __initdata = {
25 &apic_summit,
26 &apic_bigsmp,
27 &apic_es7000,
28 &apic_default, /* must be last */
29 NULL,
30};
31
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070032static int cmdline_apic;
33
34void __init generic_bigsmp_probe(void)
35{
36 /*
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
41 */
42
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",
47 genapic->name);
48 }
49}
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051void __init generic_apic_probe(char *command_line)
52{
53 char *s;
54 int i;
55 int changed = 0;
56
57 s = strstr(command_line, "apic=");
58 if (s && (s == command_line || isspace(s[-1]))) {
59 char *p = strchr(s, ' '), old;
60 if (!p)
61 p = strchr(s, '\0');
62 old = *p;
63 *p = 0;
64 for (i = 0; !changed && apic_probe[i]; i++) {
65 if (!strcmp(apic_probe[i]->name, s+5)) {
66 changed = 1;
67 genapic = apic_probe[i];
68 }
69 }
70 if (!changed)
71 printk(KERN_ERR "Unknown genapic `%s' specified.\n", s);
72 *p = old;
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070073 cmdline_apic = changed;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 }
75 for (i = 0; !changed && apic_probe[i]; i++) {
76 if (apic_probe[i]->probe()) {
77 changed = 1;
78 genapic = apic_probe[i];
79 }
80 }
81 /* Not visible without early console */
82 if (!changed)
83 panic("Didn't find an APIC driver");
84
85 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
86}
87
88/* These functions can switch the APIC even after the initial ->probe() */
89
90int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
91{
92 int i;
93 for (i = 0; apic_probe[i]; ++i) {
94 if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +020095 if (!cmdline_apic) {
96 genapic = apic_probe[i];
97 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
98 genapic->name);
99 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 return 1;
101 }
102 }
103 return 0;
104}
105
106int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
107{
108 int i;
109 for (i = 0; apic_probe[i]; ++i) {
110 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +0200111 if (!cmdline_apic) {
112 genapic = apic_probe[i];
113 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
114 genapic->name);
115 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 return 1;
117 }
118 }
119 return 0;
120}
121
122int hard_smp_processor_id(void)
123{
124 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
125}