blob: 4eeaf8801c8d1023664a51a15f0aeffd191bbafa [file] [log] [blame]
bellard574bbf72005-01-03 23:27:31 +00001/*
2 * APIC support
ths5fafdf22007-09-16 21:08:06 +00003 *
bellard574bbf72005-01-03 23:27:31 +00004 * Copyright (c) 2004-2005 Fabrice Bellard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
Blue Swirl8167ee82009-07-16 20:47:01 +000017 * License along with this library; if not, see <http://www.gnu.org/licenses/>
bellard574bbf72005-01-03 23:27:31 +000018 */
Jan Kiszkadae01682011-10-16 11:16:36 +020019#include "apic_internal.h"
Blue Swirlaa28b9b2010-03-21 19:46:26 +000020#include "apic.h"
Jan Kiszka0280b572011-02-03 22:54:11 +010021#include "ioapic.h"
aurel32bb7e7292008-10-12 20:16:03 +000022#include "host-utils.h"
Blue Swirld8023f32010-10-20 16:41:28 +000023#include "trace.h"
Jan Kiszkad96e1732011-10-07 09:19:37 +020024#include "pc.h"
bellard574bbf72005-01-03 23:27:31 +000025
bellardd3e9db92005-12-17 01:27:28 +000026#define MAX_APIC_WORDS 8
27
Michael S. Tsirkin54c96da2009-06-21 19:50:03 +030028/* Intel APIC constants: from include/asm/msidef.h */
29#define MSI_DATA_VECTOR_SHIFT 0
30#define MSI_DATA_VECTOR_MASK 0x000000ff
31#define MSI_DATA_DELIVERY_MODE_SHIFT 8
32#define MSI_DATA_TRIGGER_SHIFT 15
33#define MSI_DATA_LEVEL_SHIFT 14
34#define MSI_ADDR_DEST_MODE_SHIFT 2
35#define MSI_ADDR_DEST_ID_SHIFT 12
36#define MSI_ADDR_DEST_ID_MASK 0x00ffff0
37
Jan Kiszkae5ad9362012-02-17 18:31:19 +010038#define SYNC_FROM_VAPIC 0x1
39#define SYNC_TO_VAPIC 0x2
40#define SYNC_ISR_IRR_TO_VAPIC 0x4
41
Jan Kiszkadae01682011-10-16 11:16:36 +020042static APICCommonState *local_apics[MAX_APICS + 1];
Michael S. Tsirkin54c96da2009-06-21 19:50:03 +030043
Jan Kiszkadae01682011-10-16 11:16:36 +020044static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode);
45static void apic_update_irq(APICCommonState *s);
aliguori610626a2009-03-12 20:25:12 +000046static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
47 uint8_t dest, uint8_t dest_mode);
bellardd592d302005-07-23 19:05:37 +000048
aurel323b63c042008-12-06 10:46:35 +000049/* Find first bit starting from msb */
50static int fls_bit(uint32_t value)
51{
52 return 31 - clz32(value);
53}
54
aurel32e95f5492008-10-12 00:53:17 +000055/* Find first bit starting from lsb */
bellardd3e9db92005-12-17 01:27:28 +000056static int ffs_bit(uint32_t value)
57{
aurel32bb7e7292008-10-12 20:16:03 +000058 return ctz32(value);
bellardd3e9db92005-12-17 01:27:28 +000059}
60
61static inline void set_bit(uint32_t *tab, int index)
62{
63 int i, mask;
64 i = index >> 5;
65 mask = 1 << (index & 0x1f);
66 tab[i] |= mask;
67}
68
69static inline void reset_bit(uint32_t *tab, int index)
70{
71 int i, mask;
72 i = index >> 5;
73 mask = 1 << (index & 0x1f);
74 tab[i] &= ~mask;
75}
76
aliguori73822ec2009-01-15 20:11:34 +000077static inline int get_bit(uint32_t *tab, int index)
78{
79 int i, mask;
80 i = index >> 5;
81 mask = 1 << (index & 0x1f);
82 return !!(tab[i] & mask);
83}
84
Jan Kiszkae5ad9362012-02-17 18:31:19 +010085/* return -1 if no bit is set */
86static int get_highest_priority_int(uint32_t *tab)
87{
88 int i;
89 for (i = 7; i >= 0; i--) {
90 if (tab[i] != 0) {
91 return i * 32 + fls_bit(tab[i]);
92 }
93 }
94 return -1;
95}
96
97static void apic_sync_vapic(APICCommonState *s, int sync_type)
98{
99 VAPICState vapic_state;
100 size_t length;
101 off_t start;
102 int vector;
103
104 if (!s->vapic_paddr) {
105 return;
106 }
107 if (sync_type & SYNC_FROM_VAPIC) {
108 cpu_physical_memory_rw(s->vapic_paddr, (void *)&vapic_state,
109 sizeof(vapic_state), 0);
110 s->tpr = vapic_state.tpr;
111 }
112 if (sync_type & (SYNC_TO_VAPIC | SYNC_ISR_IRR_TO_VAPIC)) {
113 start = offsetof(VAPICState, isr);
114 length = offsetof(VAPICState, enabled) - offsetof(VAPICState, isr);
115
116 if (sync_type & SYNC_TO_VAPIC) {
117 assert(qemu_cpu_is_self(s->cpu_env));
118
119 vapic_state.tpr = s->tpr;
120 vapic_state.enabled = 1;
121 start = 0;
122 length = sizeof(VAPICState);
123 }
124
125 vector = get_highest_priority_int(s->isr);
126 if (vector < 0) {
127 vector = 0;
128 }
129 vapic_state.isr = vector & 0xf0;
130
131 vapic_state.zero = 0;
132
133 vector = get_highest_priority_int(s->irr);
134 if (vector < 0) {
135 vector = 0;
136 }
137 vapic_state.irr = vector & 0xff;
138
139 cpu_physical_memory_write_rom(s->vapic_paddr + start,
140 ((void *)&vapic_state) + start, length);
141 }
142}
143
144static void apic_vapic_base_update(APICCommonState *s)
145{
146 apic_sync_vapic(s, SYNC_TO_VAPIC);
147}
148
Jan Kiszkadae01682011-10-16 11:16:36 +0200149static void apic_local_deliver(APICCommonState *s, int vector)
aurel32a5b38b52008-04-13 16:08:30 +0000150{
aurel32a5b38b52008-04-13 16:08:30 +0000151 uint32_t lvt = s->lvt[vector];
152 int trigger_mode;
153
Blue Swirld8023f32010-10-20 16:41:28 +0000154 trace_apic_local_deliver(vector, (lvt >> 8) & 7);
155
aurel32a5b38b52008-04-13 16:08:30 +0000156 if (lvt & APIC_LVT_MASKED)
157 return;
158
159 switch ((lvt >> 8) & 7) {
160 case APIC_DM_SMI:
Blue Swirlcf6d64b2010-06-19 10:42:08 +0300161 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_SMI);
aurel32a5b38b52008-04-13 16:08:30 +0000162 break;
163
164 case APIC_DM_NMI:
Blue Swirlcf6d64b2010-06-19 10:42:08 +0300165 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_NMI);
aurel32a5b38b52008-04-13 16:08:30 +0000166 break;
167
168 case APIC_DM_EXTINT:
Blue Swirlcf6d64b2010-06-19 10:42:08 +0300169 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
aurel32a5b38b52008-04-13 16:08:30 +0000170 break;
171
172 case APIC_DM_FIXED:
173 trigger_mode = APIC_TRIGGER_EDGE;
174 if ((vector == APIC_LVT_LINT0 || vector == APIC_LVT_LINT1) &&
175 (lvt & APIC_LVT_LEVEL_TRIGGER))
176 trigger_mode = APIC_TRIGGER_LEVEL;
177 apic_set_irq(s, lvt & 0xff, trigger_mode);
178 }
179}
180
Blue Swirl92a16d72010-06-19 07:47:42 +0000181void apic_deliver_pic_intr(DeviceState *d, int level)
aurel321a7de942008-08-21 03:14:52 +0000182{
Jan Kiszkadae01682011-10-16 11:16:36 +0200183 APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
Blue Swirl92a16d72010-06-19 07:47:42 +0000184
Blue Swirlcf6d64b2010-06-19 10:42:08 +0300185 if (level) {
186 apic_local_deliver(s, APIC_LVT_LINT0);
187 } else {
aurel321a7de942008-08-21 03:14:52 +0000188 uint32_t lvt = s->lvt[APIC_LVT_LINT0];
189
190 switch ((lvt >> 8) & 7) {
191 case APIC_DM_FIXED:
192 if (!(lvt & APIC_LVT_LEVEL_TRIGGER))
193 break;
194 reset_bit(s->irr, lvt & 0xff);
195 /* fall through */
196 case APIC_DM_EXTINT:
Blue Swirlcf6d64b2010-06-19 10:42:08 +0300197 cpu_reset_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
aurel321a7de942008-08-21 03:14:52 +0000198 break;
199 }
200 }
201}
202
Jan Kiszkadae01682011-10-16 11:16:36 +0200203static void apic_external_nmi(APICCommonState *s)
Jan Kiszka02c09192011-10-18 00:00:06 +0800204{
Jan Kiszka02c09192011-10-18 00:00:06 +0800205 apic_local_deliver(s, APIC_LVT_LINT1);
206}
207
bellardd3e9db92005-12-17 01:27:28 +0000208#define foreach_apic(apic, deliver_bitmask, code) \
209{\
210 int __i, __j, __mask;\
211 for(__i = 0; __i < MAX_APIC_WORDS; __i++) {\
212 __mask = deliver_bitmask[__i];\
213 if (__mask) {\
214 for(__j = 0; __j < 32; __j++) {\
215 if (__mask & (1 << __j)) {\
216 apic = local_apics[__i * 32 + __j];\
217 if (apic) {\
218 code;\
219 }\
220 }\
221 }\
222 }\
223 }\
224}
225
ths5fafdf22007-09-16 21:08:06 +0000226static void apic_bus_deliver(const uint32_t *deliver_bitmask,
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200227 uint8_t delivery_mode, uint8_t vector_num,
bellardd592d302005-07-23 19:05:37 +0000228 uint8_t trigger_mode)
229{
Jan Kiszkadae01682011-10-16 11:16:36 +0200230 APICCommonState *apic_iter;
bellardd592d302005-07-23 19:05:37 +0000231
232 switch (delivery_mode) {
233 case APIC_DM_LOWPRI:
bellard8dd69b82005-11-23 20:59:44 +0000234 /* XXX: search for focus processor, arbitration */
bellardd3e9db92005-12-17 01:27:28 +0000235 {
236 int i, d;
237 d = -1;
238 for(i = 0; i < MAX_APIC_WORDS; i++) {
239 if (deliver_bitmask[i]) {
240 d = i * 32 + ffs_bit(deliver_bitmask[i]);
241 break;
242 }
243 }
244 if (d >= 0) {
245 apic_iter = local_apics[d];
246 if (apic_iter) {
247 apic_set_irq(apic_iter, vector_num, trigger_mode);
248 }
249 }
bellard8dd69b82005-11-23 20:59:44 +0000250 }
bellardd3e9db92005-12-17 01:27:28 +0000251 return;
bellard8dd69b82005-11-23 20:59:44 +0000252
bellardd592d302005-07-23 19:05:37 +0000253 case APIC_DM_FIXED:
bellardd592d302005-07-23 19:05:37 +0000254 break;
255
256 case APIC_DM_SMI:
aurel32e2eb9d32008-04-13 16:08:23 +0000257 foreach_apic(apic_iter, deliver_bitmask,
258 cpu_interrupt(apic_iter->cpu_env, CPU_INTERRUPT_SMI) );
259 return;
260
bellardd592d302005-07-23 19:05:37 +0000261 case APIC_DM_NMI:
aurel32e2eb9d32008-04-13 16:08:23 +0000262 foreach_apic(apic_iter, deliver_bitmask,
263 cpu_interrupt(apic_iter->cpu_env, CPU_INTERRUPT_NMI) );
264 return;
bellardd592d302005-07-23 19:05:37 +0000265
266 case APIC_DM_INIT:
267 /* normal INIT IPI sent to processors */
ths5fafdf22007-09-16 21:08:06 +0000268 foreach_apic(apic_iter, deliver_bitmask,
Gleb Natapovb09ea7d2009-06-17 23:26:59 +0300269 cpu_interrupt(apic_iter->cpu_env, CPU_INTERRUPT_INIT) );
bellardd592d302005-07-23 19:05:37 +0000270 return;
ths3b46e622007-09-17 08:09:54 +0000271
bellardd592d302005-07-23 19:05:37 +0000272 case APIC_DM_EXTINT:
bellardb1fc0342005-07-23 21:43:15 +0000273 /* handled in I/O APIC code */
bellardd592d302005-07-23 19:05:37 +0000274 break;
275
276 default:
277 return;
278 }
279
ths5fafdf22007-09-16 21:08:06 +0000280 foreach_apic(apic_iter, deliver_bitmask,
bellardd3e9db92005-12-17 01:27:28 +0000281 apic_set_irq(apic_iter, vector_num, trigger_mode) );
bellardd592d302005-07-23 19:05:37 +0000282}
bellard574bbf72005-01-03 23:27:31 +0000283
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200284void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode,
285 uint8_t vector_num, uint8_t trigger_mode)
aliguori610626a2009-03-12 20:25:12 +0000286{
287 uint32_t deliver_bitmask[MAX_APIC_WORDS];
288
Blue Swirld8023f32010-10-20 16:41:28 +0000289 trace_apic_deliver_irq(dest, dest_mode, delivery_mode, vector_num,
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200290 trigger_mode);
Blue Swirld8023f32010-10-20 16:41:28 +0000291
aliguori610626a2009-03-12 20:25:12 +0000292 apic_get_delivery_bitmask(deliver_bitmask, dest, dest_mode);
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200293 apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_mode);
aliguori610626a2009-03-12 20:25:12 +0000294}
295
Jan Kiszkadae01682011-10-16 11:16:36 +0200296static void apic_set_base(APICCommonState *s, uint64_t val)
bellard574bbf72005-01-03 23:27:31 +0000297{
ths5fafdf22007-09-16 21:08:06 +0000298 s->apicbase = (val & 0xfffff000) |
bellard574bbf72005-01-03 23:27:31 +0000299 (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE));
300 /* if disabled, cannot be enabled again */
301 if (!(val & MSR_IA32_APICBASE_ENABLE)) {
302 s->apicbase &= ~MSR_IA32_APICBASE_ENABLE;
Blue Swirl0e26b7b2010-06-19 10:42:34 +0300303 cpu_clear_apic_feature(s->cpu_env);
bellard574bbf72005-01-03 23:27:31 +0000304 s->spurious_vec &= ~APIC_SV_ENABLE;
305 }
306}
307
Jan Kiszkadae01682011-10-16 11:16:36 +0200308static void apic_set_tpr(APICCommonState *s, uint8_t val)
bellard574bbf72005-01-03 23:27:31 +0000309{
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100310 /* Updates from cr8 are ignored while the VAPIC is active */
311 if (!s->vapic_paddr) {
312 s->tpr = val << 4;
313 apic_update_irq(s);
314 }
bellard9230e662005-01-23 20:46:56 +0000315}
316
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100317static uint8_t apic_get_tpr(APICCommonState *s)
bellardd592d302005-07-23 19:05:37 +0000318{
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100319 apic_sync_vapic(s, SYNC_FROM_VAPIC);
320 return s->tpr >> 4;
bellardd592d302005-07-23 19:05:37 +0000321}
322
Jan Kiszkadae01682011-10-16 11:16:36 +0200323static int apic_get_ppr(APICCommonState *s)
bellard574bbf72005-01-03 23:27:31 +0000324{
325 int tpr, isrv, ppr;
326
327 tpr = (s->tpr >> 4);
328 isrv = get_highest_priority_int(s->isr);
329 if (isrv < 0)
330 isrv = 0;
331 isrv >>= 4;
332 if (tpr >= isrv)
333 ppr = s->tpr;
334 else
335 ppr = isrv << 4;
336 return ppr;
337}
338
Jan Kiszkadae01682011-10-16 11:16:36 +0200339static int apic_get_arb_pri(APICCommonState *s)
bellardd592d302005-07-23 19:05:37 +0000340{
341 /* XXX: arbitration */
342 return 0;
343}
344
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200345
346/*
347 * <0 - low prio interrupt,
348 * 0 - no interrupt,
349 * >0 - interrupt number
350 */
Jan Kiszkadae01682011-10-16 11:16:36 +0200351static int apic_irq_pending(APICCommonState *s)
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200352{
353 int irrv, ppr;
354 irrv = get_highest_priority_int(s->irr);
355 if (irrv < 0) {
356 return 0;
357 }
358 ppr = apic_get_ppr(s);
359 if (ppr && (irrv & 0xf0) <= (ppr & 0xf0)) {
360 return -1;
361 }
362
363 return irrv;
364}
365
bellard574bbf72005-01-03 23:27:31 +0000366/* signal the CPU if an irq is pending */
Jan Kiszkadae01682011-10-16 11:16:36 +0200367static void apic_update_irq(APICCommonState *s)
bellard574bbf72005-01-03 23:27:31 +0000368{
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200369 if (!(s->spurious_vec & APIC_SV_ENABLE)) {
bellardd592d302005-07-23 19:05:37 +0000370 return;
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200371 }
372 if (apic_irq_pending(s) > 0) {
373 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD);
Jan Kiszkad96e1732011-10-07 09:19:37 +0200374 } else if (apic_accept_pic_intr(&s->busdev.qdev) &&
375 pic_get_output(isa_pic)) {
376 apic_deliver_pic_intr(&s->busdev.qdev, 1);
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200377 }
bellard574bbf72005-01-03 23:27:31 +0000378}
379
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100380void apic_poll_irq(DeviceState *d)
381{
382 APICCommonState *s = APIC_COMMON(d);
383
384 apic_sync_vapic(s, SYNC_FROM_VAPIC);
385 apic_update_irq(s);
386}
387
Jan Kiszkadae01682011-10-16 11:16:36 +0200388static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode)
bellard574bbf72005-01-03 23:27:31 +0000389{
Jan Kiszka343270e2011-12-13 15:39:04 +0100390 apic_report_irq_delivered(!get_bit(s->irr, vector_num));
aliguori73822ec2009-01-15 20:11:34 +0000391
bellard574bbf72005-01-03 23:27:31 +0000392 set_bit(s->irr, vector_num);
393 if (trigger_mode)
394 set_bit(s->tmr, vector_num);
395 else
396 reset_bit(s->tmr, vector_num);
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100397 if (s->vapic_paddr) {
398 apic_sync_vapic(s, SYNC_ISR_IRR_TO_VAPIC);
399 /*
400 * The vcpu thread needs to see the new IRR before we pull its current
401 * TPR value. That way, if we miss a lowering of the TRP, the guest
402 * has the chance to notice the new IRR and poll for IRQs on its own.
403 */
404 smp_wmb();
405 apic_sync_vapic(s, SYNC_FROM_VAPIC);
406 }
bellard574bbf72005-01-03 23:27:31 +0000407 apic_update_irq(s);
408}
409
Jan Kiszkadae01682011-10-16 11:16:36 +0200410static void apic_eoi(APICCommonState *s)
bellard574bbf72005-01-03 23:27:31 +0000411{
412 int isrv;
413 isrv = get_highest_priority_int(s->isr);
414 if (isrv < 0)
415 return;
416 reset_bit(s->isr, isrv);
Jan Kiszka0280b572011-02-03 22:54:11 +0100417 if (!(s->spurious_vec & APIC_SV_DIRECTED_IO) && get_bit(s->tmr, isrv)) {
418 ioapic_eoi_broadcast(isrv);
419 }
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100420 apic_sync_vapic(s, SYNC_FROM_VAPIC | SYNC_TO_VAPIC);
bellard574bbf72005-01-03 23:27:31 +0000421 apic_update_irq(s);
422}
423
Gleb Natapov678e12c2009-06-10 15:40:48 +0300424static int apic_find_dest(uint8_t dest)
425{
Jan Kiszkadae01682011-10-16 11:16:36 +0200426 APICCommonState *apic = local_apics[dest];
Gleb Natapov678e12c2009-06-10 15:40:48 +0300427 int i;
428
429 if (apic && apic->id == dest)
430 return dest; /* shortcut in case apic->id == apic->idx */
431
432 for (i = 0; i < MAX_APICS; i++) {
433 apic = local_apics[i];
434 if (apic && apic->id == dest)
435 return i;
Alex Williamsonb538e532010-11-05 16:01:29 -0600436 if (!apic)
437 break;
Gleb Natapov678e12c2009-06-10 15:40:48 +0300438 }
439
440 return -1;
441}
442
bellardd3e9db92005-12-17 01:27:28 +0000443static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
444 uint8_t dest, uint8_t dest_mode)
bellardd592d302005-07-23 19:05:37 +0000445{
Jan Kiszkadae01682011-10-16 11:16:36 +0200446 APICCommonState *apic_iter;
bellardd3e9db92005-12-17 01:27:28 +0000447 int i;
bellardd592d302005-07-23 19:05:37 +0000448
449 if (dest_mode == 0) {
bellardd3e9db92005-12-17 01:27:28 +0000450 if (dest == 0xff) {
451 memset(deliver_bitmask, 0xff, MAX_APIC_WORDS * sizeof(uint32_t));
452 } else {
Gleb Natapov678e12c2009-06-10 15:40:48 +0300453 int idx = apic_find_dest(dest);
bellardd3e9db92005-12-17 01:27:28 +0000454 memset(deliver_bitmask, 0x00, MAX_APIC_WORDS * sizeof(uint32_t));
Gleb Natapov678e12c2009-06-10 15:40:48 +0300455 if (idx >= 0)
456 set_bit(deliver_bitmask, idx);
bellardd3e9db92005-12-17 01:27:28 +0000457 }
bellardd592d302005-07-23 19:05:37 +0000458 } else {
459 /* XXX: cluster mode */
bellardd3e9db92005-12-17 01:27:28 +0000460 memset(deliver_bitmask, 0x00, MAX_APIC_WORDS * sizeof(uint32_t));
461 for(i = 0; i < MAX_APICS; i++) {
462 apic_iter = local_apics[i];
463 if (apic_iter) {
464 if (apic_iter->dest_mode == 0xf) {
465 if (dest & apic_iter->log_dest)
466 set_bit(deliver_bitmask, i);
467 } else if (apic_iter->dest_mode == 0x0) {
468 if ((dest & 0xf0) == (apic_iter->log_dest & 0xf0) &&
469 (dest & apic_iter->log_dest & 0x0f)) {
470 set_bit(deliver_bitmask, i);
471 }
472 }
Alex Williamsonb538e532010-11-05 16:01:29 -0600473 } else {
474 break;
bellardd3e9db92005-12-17 01:27:28 +0000475 }
bellardd592d302005-07-23 19:05:37 +0000476 }
477 }
bellardd592d302005-07-23 19:05:37 +0000478}
479
Jan Kiszkadae01682011-10-16 11:16:36 +0200480static void apic_startup(APICCommonState *s, int vector_num)
bellarde0fd8782005-11-21 23:26:26 +0000481{
Gleb Natapovb09ea7d2009-06-17 23:26:59 +0300482 s->sipi_vector = vector_num;
483 cpu_interrupt(s->cpu_env, CPU_INTERRUPT_SIPI);
484}
485
Blue Swirl92a16d72010-06-19 07:47:42 +0000486void apic_sipi(DeviceState *d)
Gleb Natapovb09ea7d2009-06-17 23:26:59 +0300487{
Jan Kiszkadae01682011-10-16 11:16:36 +0200488 APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
Blue Swirl92a16d72010-06-19 07:47:42 +0000489
Blue Swirl4a942ce2010-06-19 10:42:31 +0300490 cpu_reset_interrupt(s->cpu_env, CPU_INTERRUPT_SIPI);
Gleb Natapovb09ea7d2009-06-17 23:26:59 +0300491
492 if (!s->wait_for_sipi)
bellarde0fd8782005-11-21 23:26:26 +0000493 return;
Blue Swirl0e26b7b2010-06-19 10:42:34 +0300494 cpu_x86_load_seg_cache_sipi(s->cpu_env, s->sipi_vector);
Gleb Natapovb09ea7d2009-06-17 23:26:59 +0300495 s->wait_for_sipi = 0;
bellarde0fd8782005-11-21 23:26:26 +0000496}
497
Blue Swirl92a16d72010-06-19 07:47:42 +0000498static void apic_deliver(DeviceState *d, uint8_t dest, uint8_t dest_mode,
bellardd592d302005-07-23 19:05:37 +0000499 uint8_t delivery_mode, uint8_t vector_num,
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200500 uint8_t trigger_mode)
bellardd592d302005-07-23 19:05:37 +0000501{
Jan Kiszkadae01682011-10-16 11:16:36 +0200502 APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
bellardd3e9db92005-12-17 01:27:28 +0000503 uint32_t deliver_bitmask[MAX_APIC_WORDS];
bellardd592d302005-07-23 19:05:37 +0000504 int dest_shorthand = (s->icr[0] >> 18) & 3;
Jan Kiszkadae01682011-10-16 11:16:36 +0200505 APICCommonState *apic_iter;
bellardd592d302005-07-23 19:05:37 +0000506
bellarde0fd8782005-11-21 23:26:26 +0000507 switch (dest_shorthand) {
bellardd3e9db92005-12-17 01:27:28 +0000508 case 0:
509 apic_get_delivery_bitmask(deliver_bitmask, dest, dest_mode);
510 break;
511 case 1:
512 memset(deliver_bitmask, 0x00, sizeof(deliver_bitmask));
Gleb Natapov678e12c2009-06-10 15:40:48 +0300513 set_bit(deliver_bitmask, s->idx);
bellardd3e9db92005-12-17 01:27:28 +0000514 break;
515 case 2:
516 memset(deliver_bitmask, 0xff, sizeof(deliver_bitmask));
517 break;
518 case 3:
519 memset(deliver_bitmask, 0xff, sizeof(deliver_bitmask));
Gleb Natapov678e12c2009-06-10 15:40:48 +0300520 reset_bit(deliver_bitmask, s->idx);
bellardd3e9db92005-12-17 01:27:28 +0000521 break;
bellarde0fd8782005-11-21 23:26:26 +0000522 }
523
bellardd592d302005-07-23 19:05:37 +0000524 switch (delivery_mode) {
bellardd592d302005-07-23 19:05:37 +0000525 case APIC_DM_INIT:
526 {
527 int trig_mode = (s->icr[0] >> 15) & 1;
528 int level = (s->icr[0] >> 14) & 1;
529 if (level == 0 && trig_mode == 1) {
ths5fafdf22007-09-16 21:08:06 +0000530 foreach_apic(apic_iter, deliver_bitmask,
bellardd3e9db92005-12-17 01:27:28 +0000531 apic_iter->arb_id = apic_iter->id );
bellardd592d302005-07-23 19:05:37 +0000532 return;
533 }
534 }
535 break;
536
537 case APIC_DM_SIPI:
ths5fafdf22007-09-16 21:08:06 +0000538 foreach_apic(apic_iter, deliver_bitmask,
bellardd3e9db92005-12-17 01:27:28 +0000539 apic_startup(apic_iter, vector_num) );
bellardd592d302005-07-23 19:05:37 +0000540 return;
541 }
542
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200543 apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_mode);
bellardd592d302005-07-23 19:05:37 +0000544}
545
Blue Swirl92a16d72010-06-19 07:47:42 +0000546int apic_get_interrupt(DeviceState *d)
bellard574bbf72005-01-03 23:27:31 +0000547{
Jan Kiszkadae01682011-10-16 11:16:36 +0200548 APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
bellard574bbf72005-01-03 23:27:31 +0000549 int intno;
550
551 /* if the APIC is installed or enabled, we let the 8259 handle the
552 IRQs */
553 if (!s)
554 return -1;
555 if (!(s->spurious_vec & APIC_SV_ENABLE))
556 return -1;
ths3b46e622007-09-17 08:09:54 +0000557
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100558 apic_sync_vapic(s, SYNC_FROM_VAPIC);
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200559 intno = apic_irq_pending(s);
560
561 if (intno == 0) {
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100562 apic_sync_vapic(s, SYNC_TO_VAPIC);
bellard574bbf72005-01-03 23:27:31 +0000563 return -1;
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200564 } else if (intno < 0) {
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100565 apic_sync_vapic(s, SYNC_TO_VAPIC);
bellardd592d302005-07-23 19:05:37 +0000566 return s->spurious_vec & 0xff;
Gleb Natapov0fbfbb52011-02-07 16:14:44 +0200567 }
bellardb4511722006-10-08 18:20:51 +0000568 reset_bit(s->irr, intno);
bellard574bbf72005-01-03 23:27:31 +0000569 set_bit(s->isr, intno);
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100570 apic_sync_vapic(s, SYNC_TO_VAPIC);
bellard574bbf72005-01-03 23:27:31 +0000571 apic_update_irq(s);
572 return intno;
573}
574
Blue Swirl92a16d72010-06-19 07:47:42 +0000575int apic_accept_pic_intr(DeviceState *d)
ths0e21e122007-10-09 03:08:56 +0000576{
Jan Kiszkadae01682011-10-16 11:16:36 +0200577 APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
ths0e21e122007-10-09 03:08:56 +0000578 uint32_t lvt0;
579
580 if (!s)
581 return -1;
582
583 lvt0 = s->lvt[APIC_LVT_LINT0];
584
aurel32a5b38b52008-04-13 16:08:30 +0000585 if ((s->apicbase & MSR_IA32_APICBASE_ENABLE) == 0 ||
586 (lvt0 & APIC_LVT_MASKED) == 0)
ths0e21e122007-10-09 03:08:56 +0000587 return 1;
588
589 return 0;
590}
591
Jan Kiszkadae01682011-10-16 11:16:36 +0200592static uint32_t apic_get_current_count(APICCommonState *s)
bellard574bbf72005-01-03 23:27:31 +0000593{
594 int64_t d;
595 uint32_t val;
Paolo Bonzini74475452011-03-11 16:47:48 +0100596 d = (qemu_get_clock_ns(vm_clock) - s->initial_count_load_time) >>
bellard574bbf72005-01-03 23:27:31 +0000597 s->count_shift;
598 if (s->lvt[APIC_LVT_TIMER] & APIC_LVT_TIMER_PERIODIC) {
599 /* periodic */
bellardd592d302005-07-23 19:05:37 +0000600 val = s->initial_count - (d % ((uint64_t)s->initial_count + 1));
bellard574bbf72005-01-03 23:27:31 +0000601 } else {
602 if (d >= s->initial_count)
603 val = 0;
604 else
605 val = s->initial_count - d;
606 }
607 return val;
608}
609
Jan Kiszkadae01682011-10-16 11:16:36 +0200610static void apic_timer_update(APICCommonState *s, int64_t current_time)
bellard574bbf72005-01-03 23:27:31 +0000611{
Jan Kiszka7a380ca2011-10-16 12:19:12 +0200612 if (apic_next_timer(s, current_time)) {
613 qemu_mod_timer(s->timer, s->next_time);
bellard574bbf72005-01-03 23:27:31 +0000614 } else {
bellard574bbf72005-01-03 23:27:31 +0000615 qemu_del_timer(s->timer);
616 }
617}
618
619static void apic_timer(void *opaque)
620{
Jan Kiszkadae01682011-10-16 11:16:36 +0200621 APICCommonState *s = opaque;
bellard574bbf72005-01-03 23:27:31 +0000622
Blue Swirlcf6d64b2010-06-19 10:42:08 +0300623 apic_local_deliver(s, APIC_LVT_TIMER);
bellard574bbf72005-01-03 23:27:31 +0000624 apic_timer_update(s, s->next_time);
625}
626
Anthony Liguoric227f092009-10-01 16:12:16 -0500627static uint32_t apic_mem_readb(void *opaque, target_phys_addr_t addr)
bellard574bbf72005-01-03 23:27:31 +0000628{
629 return 0;
630}
631
Anthony Liguoric227f092009-10-01 16:12:16 -0500632static uint32_t apic_mem_readw(void *opaque, target_phys_addr_t addr)
bellard574bbf72005-01-03 23:27:31 +0000633{
634 return 0;
635}
636
Anthony Liguoric227f092009-10-01 16:12:16 -0500637static void apic_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
bellard574bbf72005-01-03 23:27:31 +0000638{
639}
640
Anthony Liguoric227f092009-10-01 16:12:16 -0500641static void apic_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
bellard574bbf72005-01-03 23:27:31 +0000642{
643}
644
Anthony Liguoric227f092009-10-01 16:12:16 -0500645static uint32_t apic_mem_readl(void *opaque, target_phys_addr_t addr)
bellard574bbf72005-01-03 23:27:31 +0000646{
Blue Swirl92a16d72010-06-19 07:47:42 +0000647 DeviceState *d;
Jan Kiszkadae01682011-10-16 11:16:36 +0200648 APICCommonState *s;
bellard574bbf72005-01-03 23:27:31 +0000649 uint32_t val;
650 int index;
651
Blue Swirl92a16d72010-06-19 07:47:42 +0000652 d = cpu_get_current_apic();
653 if (!d) {
bellard574bbf72005-01-03 23:27:31 +0000654 return 0;
Blue Swirl0e26b7b2010-06-19 10:42:34 +0300655 }
Jan Kiszkadae01682011-10-16 11:16:36 +0200656 s = DO_UPCAST(APICCommonState, busdev.qdev, d);
bellard574bbf72005-01-03 23:27:31 +0000657
658 index = (addr >> 4) & 0xff;
659 switch(index) {
660 case 0x02: /* id */
661 val = s->id << 24;
662 break;
663 case 0x03: /* version */
664 val = 0x11 | ((APIC_LVT_NB - 1) << 16); /* version 0x11 */
665 break;
666 case 0x08:
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100667 apic_sync_vapic(s, SYNC_FROM_VAPIC);
668 if (apic_report_tpr_access) {
669 cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_READ);
670 }
bellard574bbf72005-01-03 23:27:31 +0000671 val = s->tpr;
672 break;
bellardd592d302005-07-23 19:05:37 +0000673 case 0x09:
674 val = apic_get_arb_pri(s);
675 break;
bellard574bbf72005-01-03 23:27:31 +0000676 case 0x0a:
677 /* ppr */
678 val = apic_get_ppr(s);
679 break;
aurel32b237db32008-03-28 22:31:36 +0000680 case 0x0b:
681 val = 0;
682 break;
bellardd592d302005-07-23 19:05:37 +0000683 case 0x0d:
684 val = s->log_dest << 24;
685 break;
686 case 0x0e:
687 val = s->dest_mode << 28;
688 break;
bellard574bbf72005-01-03 23:27:31 +0000689 case 0x0f:
690 val = s->spurious_vec;
691 break;
692 case 0x10 ... 0x17:
693 val = s->isr[index & 7];
694 break;
695 case 0x18 ... 0x1f:
696 val = s->tmr[index & 7];
697 break;
698 case 0x20 ... 0x27:
699 val = s->irr[index & 7];
700 break;
701 case 0x28:
702 val = s->esr;
703 break;
bellard574bbf72005-01-03 23:27:31 +0000704 case 0x30:
705 case 0x31:
706 val = s->icr[index & 1];
707 break;
bellarde0fd8782005-11-21 23:26:26 +0000708 case 0x32 ... 0x37:
709 val = s->lvt[index - 0x32];
710 break;
bellard574bbf72005-01-03 23:27:31 +0000711 case 0x38:
712 val = s->initial_count;
713 break;
714 case 0x39:
715 val = apic_get_current_count(s);
716 break;
717 case 0x3e:
718 val = s->divide_conf;
719 break;
720 default:
721 s->esr |= ESR_ILLEGAL_ADDRESS;
722 val = 0;
723 break;
724 }
Blue Swirld8023f32010-10-20 16:41:28 +0000725 trace_apic_mem_readl(addr, val);
bellard574bbf72005-01-03 23:27:31 +0000726 return val;
727}
728
Andreas Färberf5095c62010-12-19 17:22:39 +0100729static void apic_send_msi(target_phys_addr_t addr, uint32_t data)
Michael S. Tsirkin54c96da2009-06-21 19:50:03 +0300730{
731 uint8_t dest = (addr & MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT;
732 uint8_t vector = (data & MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT;
733 uint8_t dest_mode = (addr >> MSI_ADDR_DEST_MODE_SHIFT) & 0x1;
734 uint8_t trigger_mode = (data >> MSI_DATA_TRIGGER_SHIFT) & 0x1;
735 uint8_t delivery = (data >> MSI_DATA_DELIVERY_MODE_SHIFT) & 0x7;
736 /* XXX: Ignore redirection hint. */
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200737 apic_deliver_irq(dest, dest_mode, delivery, vector, trigger_mode);
Michael S. Tsirkin54c96da2009-06-21 19:50:03 +0300738}
739
Anthony Liguoric227f092009-10-01 16:12:16 -0500740static void apic_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
bellard574bbf72005-01-03 23:27:31 +0000741{
Blue Swirl92a16d72010-06-19 07:47:42 +0000742 DeviceState *d;
Jan Kiszkadae01682011-10-16 11:16:36 +0200743 APICCommonState *s;
Michael S. Tsirkin54c96da2009-06-21 19:50:03 +0300744 int index = (addr >> 4) & 0xff;
745 if (addr > 0xfff || !index) {
746 /* MSI and MMIO APIC are at the same memory location,
747 * but actually not on the global bus: MSI is on PCI bus
748 * APIC is connected directly to the CPU.
749 * Mapping them on the global bus happens to work because
750 * MSI registers are reserved in APIC MMIO and vice versa. */
751 apic_send_msi(addr, val);
752 return;
753 }
bellard574bbf72005-01-03 23:27:31 +0000754
Blue Swirl92a16d72010-06-19 07:47:42 +0000755 d = cpu_get_current_apic();
756 if (!d) {
bellard574bbf72005-01-03 23:27:31 +0000757 return;
Blue Swirl0e26b7b2010-06-19 10:42:34 +0300758 }
Jan Kiszkadae01682011-10-16 11:16:36 +0200759 s = DO_UPCAST(APICCommonState, busdev.qdev, d);
bellard574bbf72005-01-03 23:27:31 +0000760
Blue Swirld8023f32010-10-20 16:41:28 +0000761 trace_apic_mem_writel(addr, val);
bellard574bbf72005-01-03 23:27:31 +0000762
bellard574bbf72005-01-03 23:27:31 +0000763 switch(index) {
764 case 0x02:
765 s->id = (val >> 24);
766 break;
bellarde0fd8782005-11-21 23:26:26 +0000767 case 0x03:
768 break;
bellard574bbf72005-01-03 23:27:31 +0000769 case 0x08:
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100770 if (apic_report_tpr_access) {
771 cpu_report_tpr_access(s->cpu_env, TPR_ACCESS_WRITE);
772 }
bellard574bbf72005-01-03 23:27:31 +0000773 s->tpr = val;
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100774 apic_sync_vapic(s, SYNC_TO_VAPIC);
bellardd592d302005-07-23 19:05:37 +0000775 apic_update_irq(s);
bellard574bbf72005-01-03 23:27:31 +0000776 break;
bellarde0fd8782005-11-21 23:26:26 +0000777 case 0x09:
778 case 0x0a:
779 break;
bellard574bbf72005-01-03 23:27:31 +0000780 case 0x0b: /* EOI */
781 apic_eoi(s);
782 break;
bellardd592d302005-07-23 19:05:37 +0000783 case 0x0d:
784 s->log_dest = val >> 24;
785 break;
786 case 0x0e:
787 s->dest_mode = val >> 28;
788 break;
bellard574bbf72005-01-03 23:27:31 +0000789 case 0x0f:
790 s->spurious_vec = val & 0x1ff;
bellardd592d302005-07-23 19:05:37 +0000791 apic_update_irq(s);
bellard574bbf72005-01-03 23:27:31 +0000792 break;
bellarde0fd8782005-11-21 23:26:26 +0000793 case 0x10 ... 0x17:
794 case 0x18 ... 0x1f:
795 case 0x20 ... 0x27:
796 case 0x28:
797 break;
bellard574bbf72005-01-03 23:27:31 +0000798 case 0x30:
bellardd592d302005-07-23 19:05:37 +0000799 s->icr[0] = val;
Blue Swirl92a16d72010-06-19 07:47:42 +0000800 apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
bellardd592d302005-07-23 19:05:37 +0000801 (s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
Jan Kiszka1f6f4082011-08-22 17:46:31 +0200802 (s->icr[0] >> 15) & 1);
bellardd592d302005-07-23 19:05:37 +0000803 break;
bellard574bbf72005-01-03 23:27:31 +0000804 case 0x31:
bellardd592d302005-07-23 19:05:37 +0000805 s->icr[1] = val;
bellard574bbf72005-01-03 23:27:31 +0000806 break;
807 case 0x32 ... 0x37:
808 {
809 int n = index - 0x32;
810 s->lvt[n] = val;
811 if (n == APIC_LVT_TIMER)
Paolo Bonzini74475452011-03-11 16:47:48 +0100812 apic_timer_update(s, qemu_get_clock_ns(vm_clock));
bellard574bbf72005-01-03 23:27:31 +0000813 }
814 break;
815 case 0x38:
816 s->initial_count = val;
Paolo Bonzini74475452011-03-11 16:47:48 +0100817 s->initial_count_load_time = qemu_get_clock_ns(vm_clock);
bellard574bbf72005-01-03 23:27:31 +0000818 apic_timer_update(s, s->initial_count_load_time);
819 break;
bellarde0fd8782005-11-21 23:26:26 +0000820 case 0x39:
821 break;
bellard574bbf72005-01-03 23:27:31 +0000822 case 0x3e:
823 {
824 int v;
825 s->divide_conf = val & 0xb;
826 v = (s->divide_conf & 3) | ((s->divide_conf >> 1) & 4);
827 s->count_shift = (v + 1) & 7;
828 }
829 break;
830 default:
831 s->esr |= ESR_ILLEGAL_ADDRESS;
832 break;
833 }
834}
835
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100836static void apic_pre_save(APICCommonState *s)
837{
838 apic_sync_vapic(s, SYNC_FROM_VAPIC);
839}
840
Jan Kiszka7a380ca2011-10-16 12:19:12 +0200841static void apic_post_load(APICCommonState *s)
842{
843 if (s->timer_expiry != -1) {
844 qemu_mod_timer(s->timer, s->timer_expiry);
845 } else {
846 qemu_del_timer(s->timer);
847 }
848}
849
Avi Kivity312b4232011-08-15 17:17:16 +0300850static const MemoryRegionOps apic_io_ops = {
851 .old_mmio = {
852 .read = { apic_mem_readb, apic_mem_readw, apic_mem_readl, },
853 .write = { apic_mem_writeb, apic_mem_writew, apic_mem_writel, },
854 },
855 .endianness = DEVICE_NATIVE_ENDIAN,
bellard574bbf72005-01-03 23:27:31 +0000856};
857
Jan Kiszkadae01682011-10-16 11:16:36 +0200858static void apic_init(APICCommonState *s)
Blue Swirl8546b092010-06-19 07:44:07 +0000859{
Jan Kiszkadae01682011-10-16 11:16:36 +0200860 memory_region_init_io(&s->io_memory, &apic_io_ops, s, "apic-msi",
861 MSI_SPACE_SIZE);
Blue Swirl8546b092010-06-19 07:44:07 +0000862
Paolo Bonzini74475452011-03-11 16:47:48 +0100863 s->timer = qemu_new_timer_ns(vm_clock, apic_timer, s);
Blue Swirl8546b092010-06-19 07:44:07 +0000864 local_apics[s->idx] = s;
Blue Swirl8546b092010-06-19 07:44:07 +0000865}
866
Anthony Liguori999e12b2012-01-24 13:12:29 -0600867static void apic_class_init(ObjectClass *klass, void *data)
868{
869 APICCommonClass *k = APIC_COMMON_CLASS(klass);
870
871 k->init = apic_init;
872 k->set_base = apic_set_base;
873 k->set_tpr = apic_set_tpr;
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100874 k->get_tpr = apic_get_tpr;
875 k->vapic_base_update = apic_vapic_base_update;
Anthony Liguori999e12b2012-01-24 13:12:29 -0600876 k->external_nmi = apic_external_nmi;
Jan Kiszkae5ad9362012-02-17 18:31:19 +0100877 k->pre_save = apic_pre_save;
Anthony Liguori999e12b2012-01-24 13:12:29 -0600878 k->post_load = apic_post_load;
879}
880
Anthony Liguori39bffca2011-12-07 21:34:16 -0600881static TypeInfo apic_info = {
882 .name = "apic",
883 .instance_size = sizeof(APICCommonState),
884 .parent = TYPE_APIC_COMMON,
885 .class_init = apic_class_init,
Blue Swirl8546b092010-06-19 07:44:07 +0000886};
887
Andreas Färber83f7d432012-02-09 15:20:55 +0100888static void apic_register_types(void)
Blue Swirl8546b092010-06-19 07:44:07 +0000889{
Anthony Liguori39bffca2011-12-07 21:34:16 -0600890 type_register_static(&apic_info);
Blue Swirl8546b092010-06-19 07:44:07 +0000891}
892
Andreas Färber83f7d432012-02-09 15:20:55 +0100893type_init(apic_register_types)