blob: b3ba969c50d2416ed46944f382d8d7ef50f878b1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright 2004 James Cleverdon, IBM.
3 * Subject to the GNU Public License, v.2
4 *
5 * Generic APIC sub-arch probe layer.
6 *
7 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
8 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
9 * James Cleverdon.
10 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/threads.h>
12#include <linux/cpumask.h>
13#include <linux/string.h>
Ingo Molnar07c7c472007-05-02 19:27:04 +020014#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
16#include <linux/ctype.h>
17#include <linux/init.h>
Jack Steinerac23d4e2008-03-28 14:12:16 -050018#include <linux/hardirq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#include <asm/smp.h>
21#include <asm/ipi.h>
Jan Beulich00f1ea62007-05-02 19:27:04 +020022#include <asm/genapic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070024extern struct genapic apic_flat;
25extern struct genapic apic_physflat;
26extern struct genapic apic_x2xpic_uv_x;
27extern struct genapic apic_x2apic_phys;
28extern struct genapic apic_x2apic_cluster;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Ingo Molnarf18d3972007-05-02 19:27:04 +020030struct genapic __read_mostly *genapic = &apic_flat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070032static struct genapic *apic_probe[] __initdata = {
33 &apic_x2apic_uv_x,
34 &apic_x2apic_phys,
35 &apic_x2apic_cluster,
36 &apic_physflat,
37 NULL,
38};
Jack Steinerae261862008-03-28 14:12:06 -050039
Linus Torvalds1da177e2005-04-16 15:20:36 -070040/*
41 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
42 */
Ingo Molnar3c43f032007-05-02 19:27:04 +020043void __init setup_apic_routing(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070045 if (genapic == &apic_flat) {
46 if (max_physical_apicid >= 8)
47 genapic = &apic_physflat;
48 printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
49 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Ingo Molnar07c7c472007-05-02 19:27:04 +020052/* Same for both flat and physical. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Suresh Siddhacff73a62008-07-10 11:16:53 -070054void apic_send_IPI_self(int vector)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
56 __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
57}
Jack Steinerae261862008-03-28 14:12:06 -050058
59int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
60{
Yinghai Lu1b9b89e2008-07-21 22:08:21 -070061 int i;
62
63 for (i = 0; apic_probe[i]; ++i) {
64 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
65 genapic = apic_probe[i];
66 printk(KERN_INFO "Setting APIC routing to %s.\n",
67 genapic->name);
68 return 1;
69 }
Jack Steinerae261862008-03-28 14:12:06 -050070 }
71 return 0;
72}