x86: make 64bit have get_apic_id
[deliverable/linux.git] / arch / x86 / kernel / genx2apic_phys.c
1 #include <linux/threads.h>
2 #include <linux/cpumask.h>
3 #include <linux/string.h>
4 #include <linux/kernel.h>
5 #include <linux/ctype.h>
6 #include <linux/init.h>
7 #include <asm/smp.h>
8 #include <asm/ipi.h>
9 #include <asm/genapic.h>
10
11
12 /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
13
14 static cpumask_t x2apic_target_cpus(void)
15 {
16 return cpumask_of_cpu(0);
17 }
18
19 static cpumask_t x2apic_vector_allocation_domain(int cpu)
20 {
21 cpumask_t domain = CPU_MASK_NONE;
22 cpu_set(cpu, domain);
23 return domain;
24 }
25
26 static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
27 unsigned int dest)
28 {
29 unsigned long cfg;
30
31 cfg = __prepare_ICR(0, vector, dest);
32
33 /*
34 * send the IPI.
35 */
36 x2apic_icr_write(cfg, apicid);
37 }
38
39 static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
40 {
41 unsigned long flags;
42 unsigned long query_cpu;
43
44 local_irq_save(flags);
45 for_each_cpu_mask(query_cpu, mask) {
46 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
47 vector, APIC_DEST_PHYSICAL);
48 }
49 local_irq_restore(flags);
50 }
51
52 static void x2apic_send_IPI_allbutself(int vector)
53 {
54 cpumask_t mask = cpu_online_map;
55
56 cpu_clear(smp_processor_id(), mask);
57
58 if (!cpus_empty(mask))
59 x2apic_send_IPI_mask(mask, vector);
60 }
61
62 static void x2apic_send_IPI_all(int vector)
63 {
64 x2apic_send_IPI_mask(cpu_online_map, vector);
65 }
66
67 static int x2apic_apic_id_registered(void)
68 {
69 return 1;
70 }
71
72 static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
73 {
74 int cpu;
75
76 /*
77 * We're using fixed IRQ delivery, can only return one phys APIC ID.
78 * May as well be the first.
79 */
80 cpu = first_cpu(cpumask);
81 if ((unsigned)cpu < NR_CPUS)
82 return per_cpu(x86_cpu_to_apicid, cpu);
83 else
84 return BAD_APICID;
85 }
86
87 static unsigned int get_apic_id(unsigned long x)
88 {
89 unsigned int id;
90
91 id = x;
92 return id;
93 }
94
95 static unsigned long set_apic_id(unsigned int id)
96 {
97 unsigned long x;
98
99 x = id;
100 return x;
101 }
102
103 static unsigned int x2apic_read_id(void)
104 {
105 return apic_read(APIC_ID);
106 }
107
108 static unsigned int phys_pkg_id(int index_msb)
109 {
110 return x2apic_read_id() >> index_msb;
111 }
112
113 void x2apic_send_IPI_self(int vector)
114 {
115 apic_write(APIC_SELF_IPI, vector);
116 }
117
118 void init_x2apic_ldr(void)
119 {
120 return;
121 }
122
123 struct genapic apic_x2apic_phys = {
124 .name = "physical x2apic",
125 .int_delivery_mode = dest_Fixed,
126 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
127 .target_cpus = x2apic_target_cpus,
128 .vector_allocation_domain = x2apic_vector_allocation_domain,
129 .apic_id_registered = x2apic_apic_id_registered,
130 .init_apic_ldr = init_x2apic_ldr,
131 .send_IPI_all = x2apic_send_IPI_all,
132 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
133 .send_IPI_mask = x2apic_send_IPI_mask,
134 .send_IPI_self = x2apic_send_IPI_self,
135 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
136 .phys_pkg_id = phys_pkg_id,
137 .get_apic_id = get_apic_id,
138 .set_apic_id = set_apic_id,
139 .apic_id_mask = (0xFFFFFFFFu),
140 };
This page took 0.03714 seconds and 5 git commands to generate.