blob: d55fa7b187ab656f9c581b11c5dfc12f7186f82e [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 */
6#include <linux/config.h>
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 <asm/fixmap.h>
14#include <asm/mpspec.h>
15#include <asm/apicdef.h>
16#include <asm/genapic.h>
17
18extern struct genapic apic_summit;
19extern struct genapic apic_bigsmp;
20extern struct genapic apic_es7000;
21extern struct genapic apic_default;
22
23struct genapic *genapic = &apic_default;
24
25struct genapic *apic_probe[] __initdata = {
26 &apic_summit,
27 &apic_bigsmp,
28 &apic_es7000,
29 &apic_default, /* must be last */
30 NULL,
31};
32
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070033static int cmdline_apic;
34
35void __init generic_bigsmp_probe(void)
36{
37 /*
38 * This routine is used to switch to bigsmp mode when
39 * - There is no apic= option specified by the user
40 * - generic_apic_probe() has choosen apic_default as the sub_arch
41 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
42 */
43
44 if (!cmdline_apic && genapic == &apic_default)
45 if (apic_bigsmp.probe()) {
46 genapic = &apic_bigsmp;
47 printk(KERN_INFO "Overriding APIC driver with %s\n",
48 genapic->name);
49 }
50}
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052void __init generic_apic_probe(char *command_line)
53{
54 char *s;
55 int i;
56 int changed = 0;
57
58 s = strstr(command_line, "apic=");
59 if (s && (s == command_line || isspace(s[-1]))) {
60 char *p = strchr(s, ' '), old;
61 if (!p)
62 p = strchr(s, '\0');
63 old = *p;
64 *p = 0;
65 for (i = 0; !changed && apic_probe[i]; i++) {
66 if (!strcmp(apic_probe[i]->name, s+5)) {
67 changed = 1;
68 genapic = apic_probe[i];
69 }
70 }
71 if (!changed)
72 printk(KERN_ERR "Unknown genapic `%s' specified.\n", s);
73 *p = old;
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070074 cmdline_apic = changed;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 }
76 for (i = 0; !changed && apic_probe[i]; i++) {
77 if (apic_probe[i]->probe()) {
78 changed = 1;
79 genapic = apic_probe[i];
80 }
81 }
82 /* Not visible without early console */
83 if (!changed)
84 panic("Didn't find an APIC driver");
85
86 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
87}
88
89/* These functions can switch the APIC even after the initial ->probe() */
90
91int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
92{
93 int i;
94 for (i = 0; apic_probe[i]; ++i) {
95 if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +020096 if (!cmdline_apic) {
97 genapic = apic_probe[i];
98 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
99 genapic->name);
100 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 return 1;
102 }
103 }
104 return 0;
105}
106
107int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
108{
109 int i;
110 for (i = 0; apic_probe[i]; ++i) {
111 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +0200112 if (!cmdline_apic) {
113 genapic = apic_probe[i];
114 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
115 genapic->name);
116 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 return 1;
118 }
119 }
120 return 0;
121}
122
123int hard_smp_processor_id(void)
124{
125 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
126}