blob: 94b1fd9cbe3cdaef7aaed0b5dcb84bfcff12d7a4 [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>
Rusty Russell1a3f2392006-09-26 10:52:32 +020012#include <linux/errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#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
Rusty Russell1a3f2392006-09-26 10:52:32 +020033static int cmdline_apic __initdata;
34static int __init parse_apic(char *arg)
35{
36 int i;
37
38 if (!arg)
39 return -EINVAL;
40
41 for (i = 0; apic_probe[i]; i++) {
42 if (!strcmp(apic_probe[i]->name, arg)) {
43 genapic = apic_probe[i];
44 cmdline_apic = 1;
45 return 0;
46 }
47 }
48 return -ENOENT;
49}
50early_param("apic", parse_apic);
Venkatesh Pallipadi911a62d2005-09-03 15:56:31 -070051
52void __init generic_bigsmp_probe(void)
53{
54 /*
55 * This routine is used to switch to bigsmp mode when
56 * - There is no apic= option specified by the user
57 * - generic_apic_probe() has choosen apic_default as the sub_arch
58 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
59 */
60
61 if (!cmdline_apic && genapic == &apic_default)
62 if (apic_bigsmp.probe()) {
63 genapic = &apic_bigsmp;
64 printk(KERN_INFO "Overriding APIC driver with %s\n",
65 genapic->name);
66 }
67}
68
Rusty Russell1a3f2392006-09-26 10:52:32 +020069void __init generic_apic_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
Rusty Russell1a3f2392006-09-26 10:52:32 +020071 if (!cmdline_apic) {
72 int i;
73 for (i = 0; apic_probe[i]; i++) {
74 if (apic_probe[i]->probe()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 genapic = apic_probe[i];
Rusty Russell1a3f2392006-09-26 10:52:32 +020076 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 }
78 }
Rusty Russell1a3f2392006-09-26 10:52:32 +020079 /* Not visible without early console */
80 if (!apic_probe[i])
81 panic("Didn't find an APIC driver");
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
84}
85
86/* These functions can switch the APIC even after the initial ->probe() */
87
88int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid)
89{
90 int i;
91 for (i = 0; apic_probe[i]; ++i) {
92 if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +020093 if (!cmdline_apic) {
94 genapic = apic_probe[i];
95 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
96 genapic->name);
97 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 return 1;
99 }
100 }
101 return 0;
102}
103
104int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
105{
106 int i;
107 for (i = 0; apic_probe[i]; ++i) {
108 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
Jan Beulich2ba567c2006-05-30 22:47:51 +0200109 if (!cmdline_apic) {
110 genapic = apic_probe[i];
111 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
112 genapic->name);
113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 return 1;
115 }
116 }
117 return 0;
118}
119
Andi Kleen874c4fe2006-09-26 10:52:26 +0200120#ifdef CONFIG_SMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121int hard_smp_processor_id(void)
122{
123 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
124}
Andi Kleen874c4fe2006-09-26 10:52:26 +0200125#endif