ia64/xen-unstable

view linux-2.6-xen-sparse/arch/x86_64/kernel/genapic_xen.c @ 14100:e47738923a05

[LINUX] Purge include <linux/config.h>. It has been obsolete for some time now.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Fri Feb 23 16:56:45 2007 +0000 (2007-02-23)
parents fd9b2c1bb577
children
line source
1 /*
2 * Copyright 2004 James Cleverdon, IBM.
3 * Subject to the GNU Public License, v.2
4 *
5 * Xen APIC subarch code. Maximum 8 CPUs, logical delivery.
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 *
11 * Hacked to pieces for Xen by Chris Wright.
12 */
13 #include <linux/threads.h>
14 #include <linux/cpumask.h>
15 #include <linux/string.h>
16 #include <linux/kernel.h>
17 #include <linux/ctype.h>
18 #include <linux/init.h>
19 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
20 #include <asm/smp.h>
21 #include <asm/ipi.h>
22 #else
23 #include <asm/apic.h>
24 #include <asm/apicdef.h>
25 #include <asm/genapic.h>
26 #endif
27 #include <xen/evtchn.h>
29 DECLARE_PER_CPU(int, ipi_to_irq[NR_IPIS]);
31 static inline void __send_IPI_one(unsigned int cpu, int vector)
32 {
33 int irq = per_cpu(ipi_to_irq, cpu)[vector];
34 BUG_ON(irq < 0);
35 notify_remote_via_irq(irq);
36 }
38 void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
39 {
40 int cpu;
42 switch (shortcut) {
43 case APIC_DEST_SELF:
44 __send_IPI_one(smp_processor_id(), vector);
45 break;
46 case APIC_DEST_ALLBUT:
47 for (cpu = 0; cpu < NR_CPUS; ++cpu) {
48 if (cpu == smp_processor_id())
49 continue;
50 if (cpu_isset(cpu, cpu_online_map)) {
51 __send_IPI_one(cpu, vector);
52 }
53 }
54 break;
55 case APIC_DEST_ALLINC:
56 for (cpu = 0; cpu < NR_CPUS; ++cpu) {
57 if (cpu_isset(cpu, cpu_online_map)) {
58 __send_IPI_one(cpu, vector);
59 }
60 }
61 break;
62 default:
63 printk("XXXXXX __send_IPI_shortcut %08x vector %d\n", shortcut,
64 vector);
65 break;
66 }
67 }
69 static cpumask_t xen_target_cpus(void)
70 {
71 return cpu_online_map;
72 }
74 /*
75 * Set up the logical destination ID.
76 * Do nothing, not called now.
77 */
78 static void xen_init_apic_ldr(void)
79 {
80 Dprintk("%s\n", __FUNCTION__);
81 return;
82 }
84 static void xen_send_IPI_allbutself(int vector)
85 {
86 /*
87 * if there are no other CPUs in the system then
88 * we get an APIC send error if we try to broadcast.
89 * thus we have to avoid sending IPIs in this case.
90 */
91 Dprintk("%s\n", __FUNCTION__);
92 if (num_online_cpus() > 1)
93 xen_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, APIC_DEST_LOGICAL);
94 }
96 static void xen_send_IPI_all(int vector)
97 {
98 Dprintk("%s\n", __FUNCTION__);
99 xen_send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
100 }
102 static void xen_send_IPI_mask(cpumask_t cpumask, int vector)
103 {
104 unsigned long mask = cpus_addr(cpumask)[0];
105 unsigned int cpu;
106 unsigned long flags;
108 Dprintk("%s\n", __FUNCTION__);
109 local_irq_save(flags);
110 WARN_ON(mask & ~cpus_addr(cpu_online_map)[0]);
112 for (cpu = 0; cpu < NR_CPUS; ++cpu) {
113 if (cpu_isset(cpu, cpumask)) {
114 __send_IPI_one(cpu, vector);
115 }
116 }
117 local_irq_restore(flags);
118 }
120 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
121 static int xen_apic_id_registered(void)
122 {
123 /* better be set */
124 Dprintk("%s\n", __FUNCTION__);
125 return physid_isset(smp_processor_id(), phys_cpu_present_map);
126 }
127 #endif
129 static unsigned int xen_cpu_mask_to_apicid(cpumask_t cpumask)
130 {
131 Dprintk("%s\n", __FUNCTION__);
132 return cpus_addr(cpumask)[0] & APIC_ALL_CPUS;
133 }
135 static unsigned int phys_pkg_id(int index_msb)
136 {
137 u32 ebx;
139 Dprintk("%s\n", __FUNCTION__);
140 ebx = cpuid_ebx(1);
141 return ((ebx >> 24) & 0xFF) >> index_msb;
142 }
144 struct genapic apic_xen = {
145 .name = "xen",
146 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
147 .int_delivery_mode = dest_LowestPrio,
148 #endif
149 .int_dest_mode = (APIC_DEST_LOGICAL != 0),
150 .int_delivery_dest = APIC_DEST_LOGICAL | APIC_DM_LOWEST,
151 .target_cpus = xen_target_cpus,
152 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
153 .apic_id_registered = xen_apic_id_registered,
154 #endif
155 .init_apic_ldr = xen_init_apic_ldr,
156 .send_IPI_all = xen_send_IPI_all,
157 .send_IPI_allbutself = xen_send_IPI_allbutself,
158 .send_IPI_mask = xen_send_IPI_mask,
159 .cpu_mask_to_apicid = xen_cpu_mask_to_apicid,
160 .phys_pkg_id = phys_pkg_id,
161 };