probe_64.c 2.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Copyright 2004 James Cleverdon, IBM.
 * Subject to the GNU Public License, v.2
 *
 * Generic APIC sub-arch probe layer.
 *
 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
 * James Cleverdon.
 */
#include <linux/threads.h>
#include <linux/cpumask.h>
#include <linux/string.h>
14
#include <linux/module.h>
L
Linus Torvalds 已提交
15 16 17
#include <linux/kernel.h>
#include <linux/ctype.h>
#include <linux/init.h>
J
Jack Steiner 已提交
18
#include <linux/hardirq.h>
19
#include <linux/dmar.h>
L
Linus Torvalds 已提交
20 21

#include <asm/smp.h>
I
Ingo Molnar 已提交
22
#include <asm/apic.h>
Y
Yinghai Lu 已提交
23
#include <asm/ipi.h>
24
#include <asm/setup.h>
L
Linus Torvalds 已提交
25

26 27 28 29 30
extern struct apic apic_flat;
extern struct apic apic_physflat;
extern struct apic apic_x2xpic_uv_x;
extern struct apic apic_x2apic_phys;
extern struct apic apic_x2apic_cluster;
L
Linus Torvalds 已提交
31

32
struct apic __read_mostly *apic = &apic_flat;
33
EXPORT_SYMBOL_GPL(apic);
L
Linus Torvalds 已提交
34

35
static struct apic *apic_probe[] __initdata = {
N
Nick Piggin 已提交
36
#ifdef CONFIG_X86_UV
37
	&apic_x2apic_uv_x,
N
Nick Piggin 已提交
38
#endif
Y
Yinghai Lu 已提交
39
#ifdef CONFIG_X86_X2APIC
40 41
	&apic_x2apic_phys,
	&apic_x2apic_cluster,
Y
Yinghai Lu 已提交
42
#endif
43 44 45
	&apic_physflat,
	NULL,
};
46

L
Linus Torvalds 已提交
47 48 49
/*
 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
 */
50
void __init default_setup_apic_routing(void)
L
Linus Torvalds 已提交
51
{
Y
Yinghai Lu 已提交
52
#ifdef CONFIG_X86_X2APIC
53 54 55 56 57 58 59 60 61 62
	if (x2apic && (apic != &apic_x2apic_phys &&
#ifdef CONFIG_X86_UV
		       apic != &apic_x2apic_uv_x &&
#endif
		       apic != &apic_x2apic_cluster)) {
		if (x2apic_phys)
			apic = &apic_x2apic_phys;
		else
			apic = &apic_x2apic_cluster;
		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
63
	}
Y
Yinghai Lu 已提交
64
#endif
65

I
Ingo Molnar 已提交
66
	if (apic == &apic_flat) {
67
		if (max_physical_apicid >= 8)
I
Ingo Molnar 已提交
68 69
			apic = &apic_physflat;
		printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
70
	}
71 72 73 74 75 76 77

	/*
	 * Now that apic routing model is selected, configure the
	 * fault handling for intr remapping.
	 */
	if (intr_remapping_enabled)
		enable_drhd_fault_handling();
L
Linus Torvalds 已提交
78 79
}

80
/* Same for both flat and physical. */
L
Linus Torvalds 已提交
81

82
void apic_send_IPI_self(int vector)
L
Linus Torvalds 已提交
83
{
84
	__default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
L
Linus Torvalds 已提交
85
}
86

87
int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
88
{
89 90 91 92
	int i;

	for (i = 0; apic_probe[i]; ++i) {
		if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
I
Ingo Molnar 已提交
93
			apic = apic_probe[i];
94
			printk(KERN_INFO "Setting APIC routing to %s.\n",
I
Ingo Molnar 已提交
95
				apic->name);
96 97
			return 1;
		}
98 99 100
	}
	return 0;
}