Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright 2004 James Cleverdon, IBM. | |
3 | * Subject to the GNU Public License, v.2 | |
4 | * | |
f8d31193 | 5 | * Flat APIC subarch code. |
1da177e4 LT |
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 | */ | |
f19cccf3 | 11 | #include <linux/errno.h> |
1da177e4 LT |
12 | #include <linux/threads.h> |
13 | #include <linux/cpumask.h> | |
14 | #include <linux/string.h> | |
15 | #include <linux/kernel.h> | |
16 | #include <linux/ctype.h> | |
17 | #include <linux/init.h> | |
0c81c746 | 18 | #include <linux/hardirq.h> |
1da177e4 LT |
19 | #include <asm/smp.h> |
20 | #include <asm/ipi.h> | |
00f1ea69 | 21 | #include <asm/genapic.h> |
0c81c746 | 22 | #include <mach_apicdef.h> |
1da177e4 | 23 | |
1da177e4 LT |
24 | static cpumask_t flat_target_cpus(void) |
25 | { | |
26 | return cpu_online_map; | |
27 | } | |
28 | ||
c7111c13 EB |
29 | static cpumask_t flat_vector_allocation_domain(int cpu) |
30 | { | |
31 | /* Careful. Some cpus do not strictly honor the set of cpus | |
32 | * specified in the interrupt destination when using lowest | |
33 | * priority interrupt delivery mode. | |
34 | * | |
35 | * In particular there was a hyperthreading cpu observed to | |
36 | * deliver interrupts to the wrong hyperthread when only one | |
37 | * hyperthread was specified in the interrupt desitination. | |
38 | */ | |
39 | cpumask_t domain = { { [0] = APIC_ALL_CPUS, } }; | |
40 | return domain; | |
41 | } | |
42 | ||
1da177e4 LT |
43 | /* |
44 | * Set up the logical destination ID. | |
45 | * | |
46 | * Intel recommends to set DFR, LDR and TPR before enabling | |
47 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel | |
48 | * document number 292116). So here it goes... | |
49 | */ | |
50 | static void flat_init_apic_ldr(void) | |
51 | { | |
52 | unsigned long val; | |
53 | unsigned long num, id; | |
54 | ||
55 | num = smp_processor_id(); | |
56 | id = 1UL << num; | |
eddfb4ed | 57 | apic_write(APIC_DFR, APIC_DFR_FLAT); |
1da177e4 LT |
58 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; |
59 | val |= SET_APIC_LOGICAL_ID(id); | |
eddfb4ed | 60 | apic_write(APIC_LDR, val); |
1da177e4 LT |
61 | } |
62 | ||
1da177e4 LT |
63 | static void flat_send_IPI_mask(cpumask_t cpumask, int vector) |
64 | { | |
65 | unsigned long mask = cpus_addr(cpumask)[0]; | |
1da177e4 LT |
66 | unsigned long flags; |
67 |