4 * Copyright (c) 2004-2005 Fabrice Bellard
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.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
22 #include "qemu-timer.h"
23 #include "host-utils.h"
27 /* APIC Local Vector Table */
28 #define APIC_LVT_TIMER 0
29 #define APIC_LVT_THERMAL 1
30 #define APIC_LVT_PERFORM 2
31 #define APIC_LVT_LINT0 3
32 #define APIC_LVT_LINT1 4
33 #define APIC_LVT_ERROR 5
36 /* APIC delivery modes */
37 #define APIC_DM_FIXED 0
38 #define APIC_DM_LOWPRI 1
41 #define APIC_DM_INIT 5
42 #define APIC_DM_SIPI 6
43 #define APIC_DM_EXTINT 7
45 /* APIC destination mode */
46 #define APIC_DESTMODE_FLAT 0xf
47 #define APIC_DESTMODE_CLUSTER 1
49 #define APIC_TRIGGER_EDGE 0
50 #define APIC_TRIGGER_LEVEL 1
52 #define APIC_LVT_TIMER_PERIODIC (1<<17)
53 #define APIC_LVT_MASKED (1<<16)
54 #define APIC_LVT_LEVEL_TRIGGER (1<<15)
55 #define APIC_LVT_REMOTE_IRR (1<<14)
56 #define APIC_INPUT_POLARITY (1<<13)
57 #define APIC_SEND_PENDING (1<<12)
59 #define ESR_ILLEGAL_ADDRESS (1 << 7)
61 #define APIC_SV_ENABLE (1 << 8)
64 #define MAX_APIC_WORDS 8
66 typedef struct APICState
{
72 uint32_t spurious_vec
;
75 uint32_t isr
[8]; /* in service register */
76 uint32_t tmr
[8]; /* trigger mode register */
77 uint32_t irr
[8]; /* interrupt request register */
78 uint32_t lvt
[APIC_LVT_NB
];
79 uint32_t esr
; /* error register */
84 uint32_t initial_count
;
85 int64_t initial_count_load_time
, next_time
;
92 static int apic_io_memory
;
93 static APICState
*local_apics
[MAX_APICS
+ 1];
94 static int last_apic_idx
= 0;
95 static int apic_irq_delivered
;
98 static void apic_set_irq(APICState
*s
, int vector_num
, int trigger_mode
);
99 static void apic_update_irq(APICState
*s
);
100 static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask
,
101 uint8_t dest
, uint8_t dest_mode
);
103 /* Find first bit starting from msb */
104 static int fls_bit(uint32_t value
)
106 return 31 - clz32(value
);
109 /* Find first bit starting from lsb */
110 static int ffs_bit(uint32_t value
)
115 static inline void set_bit(uint32_t *tab
, int index
)
119 mask
= 1 << (index
& 0x1f);
123 static inline void reset_bit(uint32_t *tab
, int index
)
127 mask
= 1 << (index
& 0x1f);
131 static inline int get_bit(uint32_t *tab
, int index
)
135 mask
= 1 << (index
& 0x1f);
136 return !!(tab
[i
] & mask
);
139 static void apic_local_deliver(CPUState
*env
, int vector
)
141 APICState
*s
= env
->apic_state
;
142 uint32_t lvt
= s
->lvt
[vector
];
145 if (lvt
& APIC_LVT_MASKED
)
148 switch ((lvt
>> 8) & 7) {
150 cpu_interrupt(env
, CPU_INTERRUPT_SMI
);
154 cpu_interrupt(env
, CPU_INTERRUPT_NMI
);
158 cpu_interrupt(env
, CPU_INTERRUPT_HARD
);
162 trigger_mode
= APIC_TRIGGER_EDGE
;
163 if ((vector
== APIC_LVT_LINT0
|| vector
== APIC_LVT_LINT1
) &&
164 (lvt
& APIC_LVT_LEVEL_TRIGGER
))
165 trigger_mode
= APIC_TRIGGER_LEVEL
;
166 apic_set_irq(s
, lvt
& 0xff, trigger_mode
);
170 void apic_deliver_pic_intr(CPUState
*env
, int level
)
173 apic_local_deliver(env
, APIC_LVT_LINT0
);
175 APICState
*s
= env
->apic_state
;
176 uint32_t lvt
= s
->lvt
[APIC_LVT_LINT0
];
178 switch ((lvt
>> 8) & 7) {
180 if (!(lvt
& APIC_LVT_LEVEL_TRIGGER
))
182 reset_bit(s
->irr
, lvt
& 0xff);
185 cpu_reset_interrupt(env
, CPU_INTERRUPT_HARD
);
191 #define foreach_apic(apic, deliver_bitmask, code) \
193 int __i, __j, __mask;\
194 for(__i = 0; __i < MAX_APIC_WORDS; __i++) {\
195 __mask = deliver_bitmask[__i];\
197 for(__j = 0; __j < 32; __j++) {\
198 if (__mask & (1 << __j)) {\
199 apic = local_apics[__i * 32 + __j];\
209 static void apic_bus_deliver(const uint32_t *deliver_bitmask
,
210 uint8_t delivery_mode
,
211 uint8_t vector_num
, uint8_t polarity
,
212 uint8_t trigger_mode
)
214 APICState
*apic_iter
;
216 switch (delivery_mode
) {
218 /* XXX: search for focus processor, arbitration */
222 for(i
= 0; i
< MAX_APIC_WORDS
; i
++) {
223 if (deliver_bitmask
[i
]) {
224 d
= i
* 32 + ffs_bit(deliver_bitmask
[i
]);
229 apic_iter
= local_apics
[d
];
231 apic_set_irq(apic_iter
, vector_num
, trigger_mode
);
241 foreach_apic(apic_iter
, deliver_bitmask
,
242 cpu_interrupt(apic_iter
->cpu_env
, CPU_INTERRUPT_SMI
) );
246 foreach_apic(apic_iter
, deliver_bitmask
,
247 cpu_interrupt(apic_iter
->cpu_env
, CPU_INTERRUPT_NMI
) );
251 /* normal INIT IPI sent to processors */
252 foreach_apic(apic_iter
, deliver_bitmask
,
253 cpu_interrupt(apic_iter
->cpu_env
, CPU_INTERRUPT_INIT
) );
257 /* handled in I/O APIC code */
264 foreach_apic(apic_iter
, deliver_bitmask
,
265 apic_set_irq(apic_iter
, vector_num
, trigger_mode
) );
268 void apic_deliver_irq(uint8_t dest
, uint8_t dest_mode
,
269 uint8_t delivery_mode
, uint8_t vector_num
,
270 uint8_t polarity
, uint8_t trigger_mode
)
272 uint32_t deliver_bitmask
[MAX_APIC_WORDS
];
274 apic_get_delivery_bitmask(deliver_bitmask
, dest
, dest_mode
);
275 apic_bus_deliver(deliver_bitmask
, delivery_mode
, vector_num
, polarity
,
279 void cpu_set_apic_base(CPUState
*env
, uint64_t val
)
281 APICState
*s
= env
->apic_state
;
283 printf("cpu_set_apic_base: %016" PRIx64
"\n", val
);
287 s
->apicbase
= (val
& 0xfffff000) |
288 (s
->apicbase
& (MSR_IA32_APICBASE_BSP
| MSR_IA32_APICBASE_ENABLE
));
289 /* if disabled, cannot be enabled again */
290 if (!(val
& MSR_IA32_APICBASE_ENABLE
)) {
291 s
->apicbase
&= ~MSR_IA32_APICBASE_ENABLE
;
292 env
->cpuid_features
&= ~CPUID_APIC
;
293 s
->spurious_vec
&= ~APIC_SV_ENABLE
;
297 uint64_t cpu_get_apic_base(CPUState
*env
)
299 APICState
*s
= env
->apic_state
;
301 printf("cpu_get_apic_base: %016" PRIx64
"\n",
302 s
? (uint64_t)s
->apicbase
: 0);
304 return s
? s
->apicbase
: 0;
307 void cpu_set_apic_tpr(CPUX86State
*env
, uint8_t val
)
309 APICState
*s
= env
->apic_state
;
312 s
->tpr
= (val
& 0x0f) << 4;
316 uint8_t cpu_get_apic_tpr(CPUX86State
*env
)
318 APICState
*s
= env
->apic_state
;
319 return s
? s
->tpr
>> 4 : 0;
322 /* return -1 if no bit is set */
323 static int get_highest_priority_int(uint32_t *tab
)
326 for(i
= 7; i
>= 0; i
--) {
328 return i
* 32 + fls_bit(tab
[i
]);
334 static int apic_get_ppr(APICState
*s
)
339 isrv
= get_highest_priority_int(s
->isr
);
350 static int apic_get_arb_pri(APICState
*s
)
352 /* XXX: arbitration */
356 /* signal the CPU if an irq is pending */
357 static void apic_update_irq(APICState
*s
)
360 if (!(s
->spurious_vec
& APIC_SV_ENABLE
))
362 irrv
= get_highest_priority_int(s
->irr
);
365 ppr
= apic_get_ppr(s
);
366 if (ppr
&& (irrv
& 0xf0) <= (ppr
& 0xf0))
368 cpu_interrupt(s
->cpu_env
, CPU_INTERRUPT_HARD
);
371 void apic_reset_irq_delivered(void)
373 apic_irq_delivered
= 0;
376 int apic_get_irq_delivered(void)
378 return apic_irq_delivered
;
381 static void apic_set_irq(APICState
*s
, int vector_num
, int trigger_mode
)
383 apic_irq_delivered
+= !get_bit(s
->irr
, vector_num
);
385 set_bit(s
->irr
, vector_num
);
387 set_bit(s
->tmr
, vector_num
);
389 reset_bit(s
->tmr
, vector_num
);
393 static void apic_eoi(APICState
*s
)
396 isrv
= get_highest_priority_int(s
->isr
);
399 reset_bit(s
->isr
, isrv
);
400 /* XXX: send the EOI packet to the APIC bus to allow the I/O APIC to
401 set the remote IRR bit for level triggered interrupts. */
405 static int apic_find_dest(uint8_t dest
)
407 APICState
*apic
= local_apics
[dest
];
410 if (apic
&& apic
->id
== dest
)
411 return dest
; /* shortcut in case apic->id == apic->idx */
413 for (i
= 0; i
< MAX_APICS
; i
++) {
414 apic
= local_apics
[i
];
415 if (apic
&& apic
->id
== dest
)
422 static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask
,
423 uint8_t dest
, uint8_t dest_mode
)
425 APICState
*apic_iter
;
428 if (dest_mode
== 0) {
430 memset(deliver_bitmask
, 0xff, MAX_APIC_WORDS
* sizeof(uint32_t));
432 int idx
= apic_find_dest(dest
);
433 memset(deliver_bitmask
, 0x00, MAX_APIC_WORDS
* sizeof(uint32_t));
435 set_bit(deliver_bitmask
, idx
);
438 /* XXX: cluster mode */
439 memset(deliver_bitmask
, 0x00, MAX_APIC_WORDS
* sizeof(uint32_t));
440 for(i
= 0; i
< MAX_APICS
; i
++) {
441 apic_iter
= local_apics
[i
];
443 if (apic_iter
->dest_mode
== 0xf) {
444 if (dest
& apic_iter
->log_dest
)
445 set_bit(deliver_bitmask
, i
);
446 } else if (apic_iter
->dest_mode
== 0x0) {
447 if ((dest
& 0xf0) == (apic_iter
->log_dest
& 0xf0) &&
448 (dest
& apic_iter
->log_dest
& 0x0f)) {
449 set_bit(deliver_bitmask
, i
);
458 void apic_init_reset(CPUState
*env
)
460 APICState
*s
= env
->apic_state
;
467 s
->spurious_vec
= 0xff;
470 memset(s
->isr
, 0, sizeof(s
->isr
));
471 memset(s
->tmr
, 0, sizeof(s
->tmr
));
472 memset(s
->irr
, 0, sizeof(s
->irr
));
473 for(i
= 0; i
< APIC_LVT_NB
; i
++)
474 s
->lvt
[i
] = 1 << 16; /* mask LVT */
476 memset(s
->icr
, 0, sizeof(s
->icr
));
479 s
->initial_count
= 0;
480 s
->initial_count_load_time
= 0;
482 s
->wait_for_sipi
= 1;
484 env
->halted
= !(s
->apicbase
& MSR_IA32_APICBASE_BSP
);
487 static void apic_startup(APICState
*s
, int vector_num
)
489 s
->sipi_vector
= vector_num
;
490 cpu_interrupt(s
->cpu_env
, CPU_INTERRUPT_SIPI
);
493 void apic_sipi(CPUState
*env
)
495 APICState
*s
= env
->apic_state
;
497 cpu_reset_interrupt(env
, CPU_INTERRUPT_SIPI
);
499 if (!s
->wait_for_sipi
)
503 cpu_x86_load_seg_cache(env
, R_CS
, s
->sipi_vector
<< 8, s
->sipi_vector
<< 12,
506 s
->wait_for_sipi
= 0;
509 static void apic_deliver(APICState
*s
, uint8_t dest
, uint8_t dest_mode
,
510 uint8_t delivery_mode
, uint8_t vector_num
,
511 uint8_t polarity
, uint8_t trigger_mode
)
513 uint32_t deliver_bitmask
[MAX_APIC_WORDS
];
514 int dest_shorthand
= (s
->icr
[0] >> 18) & 3;
515 APICState
*apic_iter
;
517 switch (dest_shorthand
) {
519 apic_get_delivery_bitmask(deliver_bitmask
, dest
, dest_mode
);
522 memset(deliver_bitmask
, 0x00, sizeof(deliver_bitmask
));
523 set_bit(deliver_bitmask
, s
->idx
);
526 memset(deliver_bitmask
, 0xff, sizeof(deliver_bitmask
));
529 memset(deliver_bitmask
, 0xff, sizeof(deliver_bitmask
));
530 reset_bit(deliver_bitmask
, s
->idx
);
534 switch (delivery_mode
) {
537 int trig_mode
= (s
->icr
[0] >> 15) & 1;
538 int level
= (s
->icr
[0] >> 14) & 1;
539 if (level
== 0 && trig_mode
== 1) {
540 foreach_apic(apic_iter
, deliver_bitmask
,
541 apic_iter
->arb_id
= apic_iter
->id
);
548 foreach_apic(apic_iter
, deliver_bitmask
,
549 apic_startup(apic_iter
, vector_num
) );
553 apic_bus_deliver(deliver_bitmask
, delivery_mode
, vector_num
, polarity
,
557 int apic_get_interrupt(CPUState
*env
)
559 APICState
*s
= env
->apic_state
;
562 /* if the APIC is installed or enabled, we let the 8259 handle the
566 if (!(s
->spurious_vec
& APIC_SV_ENABLE
))
569 /* XXX: spurious IRQ handling */
570 intno
= get_highest_priority_int(s
->irr
);
573 if (s
->tpr
&& intno
<= s
->tpr
)
574 return s
->spurious_vec
& 0xff;
575 reset_bit(s
->irr
, intno
);
576 set_bit(s
->isr
, intno
);
581 int apic_accept_pic_intr(CPUState
*env
)
583 APICState
*s
= env
->apic_state
;
589 lvt0
= s
->lvt
[APIC_LVT_LINT0
];
591 if ((s
->apicbase
& MSR_IA32_APICBASE_ENABLE
) == 0 ||
592 (lvt0
& APIC_LVT_MASKED
) == 0)
598 static uint32_t apic_get_current_count(APICState
*s
)
602 d
= (qemu_get_clock(vm_clock
) - s
->initial_count_load_time
) >>
604 if (s
->lvt
[APIC_LVT_TIMER
] & APIC_LVT_TIMER_PERIODIC
) {
606 val
= s
->initial_count
- (d
% ((uint64_t)s
->initial_count
+ 1));
608 if (d
>= s
->initial_count
)
611 val
= s
->initial_count
- d
;
616 static void apic_timer_update(APICState
*s
, int64_t current_time
)
618 int64_t next_time
, d
;
620 if (!(s
->lvt
[APIC_LVT_TIMER
] & APIC_LVT_MASKED
)) {
621 d
= (current_time
- s
->initial_count_load_time
) >>
623 if (s
->lvt
[APIC_LVT_TIMER
] & APIC_LVT_TIMER_PERIODIC
) {
624 if (!s
->initial_count
)
626 d
= ((d
/ ((uint64_t)s
->initial_count
+ 1)) + 1) * ((uint64_t)s
->initial_count
+ 1);
628 if (d
>= s
->initial_count
)
630 d
= (uint64_t)s
->initial_count
+ 1;
632 next_time
= s
->initial_count_load_time
+ (d
<< s
->count_shift
);
633 qemu_mod_timer(s
->timer
, next_time
);
634 s
->next_time
= next_time
;
637 qemu_del_timer(s
->timer
);
641 static void apic_timer(void *opaque
)
643 APICState
*s
= opaque
;
645 apic_local_deliver(s
->cpu_env
, APIC_LVT_TIMER
);
646 apic_timer_update(s
, s
->next_time
);
649 static uint32_t apic_mem_readb(void *opaque
, target_phys_addr_t addr
)
654 static uint32_t apic_mem_readw(void *opaque
, target_phys_addr_t addr
)
659 static void apic_mem_writeb(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
663 static void apic_mem_writew(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
667 static uint32_t apic_mem_readl(void *opaque
, target_phys_addr_t addr
)
674 env
= cpu_single_env
;
679 index
= (addr
>> 4) & 0xff;
684 case 0x03: /* version */
685 val
= 0x11 | ((APIC_LVT_NB
- 1) << 16); /* version 0x11 */
691 val
= apic_get_arb_pri(s
);
695 val
= apic_get_ppr(s
);
701 val
= s
->log_dest
<< 24;
704 val
= s
->dest_mode
<< 28;
707 val
= s
->spurious_vec
;
710 val
= s
->isr
[index
& 7];
713 val
= s
->tmr
[index
& 7];
716 val
= s
->irr
[index
& 7];
723 val
= s
->icr
[index
& 1];
726 val
= s
->lvt
[index
- 0x32];
729 val
= s
->initial_count
;
732 val
= apic_get_current_count(s
);
735 val
= s
->divide_conf
;
738 s
->esr
|= ESR_ILLEGAL_ADDRESS
;
743 printf("APIC read: %08x = %08x\n", (uint32_t)addr
, val
);
748 static void apic_mem_writel(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
754 env
= cpu_single_env
;
760 printf("APIC write: %08x = %08x\n", (uint32_t)addr
, val
);
763 index
= (addr
>> 4) & 0xff;
781 s
->log_dest
= val
>> 24;
784 s
->dest_mode
= val
>> 28;
787 s
->spurious_vec
= val
& 0x1ff;
797 apic_deliver(s
, (s
->icr
[1] >> 24) & 0xff, (s
->icr
[0] >> 11) & 1,
798 (s
->icr
[0] >> 8) & 7, (s
->icr
[0] & 0xff),
799 (s
->icr
[0] >> 14) & 1, (s
->icr
[0] >> 15) & 1);
806 int n
= index
- 0x32;
808 if (n
== APIC_LVT_TIMER
)
809 apic_timer_update(s
, qemu_get_clock(vm_clock
));
813 s
->initial_count
= val
;
814 s
->initial_count_load_time
= qemu_get_clock(vm_clock
);
815 apic_timer_update(s
, s
->initial_count_load_time
);
822 s
->divide_conf
= val
& 0xb;
823 v
= (s
->divide_conf
& 3) | ((s
->divide_conf
>> 1) & 4);
824 s
->count_shift
= (v
+ 1) & 7;
828 s
->esr
|= ESR_ILLEGAL_ADDRESS
;
833 static void apic_save(QEMUFile
*f
, void *opaque
)
835 APICState
*s
= opaque
;
838 qemu_put_be32s(f
, &s
->apicbase
);
839 qemu_put_8s(f
, &s
->id
);
840 qemu_put_8s(f
, &s
->arb_id
);
841 qemu_put_8s(f
, &s
->tpr
);
842 qemu_put_be32s(f
, &s
->spurious_vec
);
843 qemu_put_8s(f
, &s
->log_dest
);
844 qemu_put_8s(f
, &s
->dest_mode
);
845 for (i
= 0; i
< 8; i
++) {
846 qemu_put_be32s(f
, &s
->isr
[i
]);
847 qemu_put_be32s(f
, &s
->tmr
[i
]);
848 qemu_put_be32s(f
, &s
->irr
[i
]);
850 for (i
= 0; i
< APIC_LVT_NB
; i
++) {
851 qemu_put_be32s(f
, &s
->lvt
[i
]);
853 qemu_put_be32s(f
, &s
->esr
);
854 qemu_put_be32s(f
, &s
->icr
[0]);
855 qemu_put_be32s(f
, &s
->icr
[1]);
856 qemu_put_be32s(f
, &s
->divide_conf
);
857 qemu_put_be32(f
, s
->count_shift
);
858 qemu_put_be32s(f
, &s
->initial_count
);
859 qemu_put_be64(f
, s
->initial_count_load_time
);
860 qemu_put_be64(f
, s
->next_time
);
862 qemu_put_timer(f
, s
->timer
);
865 static int apic_load(QEMUFile
*f
, void *opaque
, int version_id
)
867 APICState
*s
= opaque
;
873 /* XXX: what if the base changes? (registered memory regions) */
874 qemu_get_be32s(f
, &s
->apicbase
);
875 qemu_get_8s(f
, &s
->id
);
876 qemu_get_8s(f
, &s
->arb_id
);
877 qemu_get_8s(f
, &s
->tpr
);
878 qemu_get_be32s(f
, &s
->spurious_vec
);
879 qemu_get_8s(f
, &s
->log_dest
);
880 qemu_get_8s(f
, &s
->dest_mode
);
881 for (i
= 0; i
< 8; i
++) {
882 qemu_get_be32s(f
, &s
->isr
[i
]);
883 qemu_get_be32s(f
, &s
->tmr
[i
]);
884 qemu_get_be32s(f
, &s
->irr
[i
]);
886 for (i
= 0; i
< APIC_LVT_NB
; i
++) {
887 qemu_get_be32s(f
, &s
->lvt
[i
]);
889 qemu_get_be32s(f
, &s
->esr
);
890 qemu_get_be32s(f
, &s
->icr
[0]);
891 qemu_get_be32s(f
, &s
->icr
[1]);
892 qemu_get_be32s(f
, &s
->divide_conf
);
893 s
->count_shift
=qemu_get_be32(f
);
894 qemu_get_be32s(f
, &s
->initial_count
);
895 s
->initial_count_load_time
=qemu_get_be64(f
);
896 s
->next_time
=qemu_get_be64(f
);
899 qemu_get_timer(f
, s
->timer
);
903 static void apic_reset(void *opaque
)
905 APICState
*s
= opaque
;
906 int bsp
= cpu_is_bsp(s
->cpu_env
);
908 s
->apicbase
= 0xfee00000 |
909 (bsp
? MSR_IA32_APICBASE_BSP
: 0) | MSR_IA32_APICBASE_ENABLE
;
911 cpu_reset(s
->cpu_env
);
912 apic_init_reset(s
->cpu_env
);
916 * LINT0 delivery mode on CPU #0 is set to ExtInt at initialization
917 * time typically by BIOS, so PIC interrupt can be delivered to the
918 * processor when local APIC is enabled.
920 s
->lvt
[APIC_LVT_LINT0
] = 0x700;
924 static CPUReadMemoryFunc
*apic_mem_read
[3] = {
930 static CPUWriteMemoryFunc
*apic_mem_write
[3] = {
936 int apic_init(CPUState
*env
)
940 if (last_apic_idx
>= MAX_APICS
)
942 s
= qemu_mallocz(sizeof(APICState
));
944 s
->idx
= last_apic_idx
++;
945 s
->id
= env
->cpuid_apic_id
;
950 /* XXX: mapping more APICs at the same memory location */
951 if (apic_io_memory
== 0) {
952 /* NOTE: the APIC is directly connected to the CPU - it is not
953 on the global memory bus. */
954 apic_io_memory
= cpu_register_io_memory(apic_mem_read
,
955 apic_mem_write
, NULL
);
956 cpu_register_physical_memory(s
->apicbase
& ~0xfff, 0x1000,
959 s
->timer
= qemu_new_timer(vm_clock
, apic_timer
, s
);
961 register_savevm("apic", s
->idx
, 2, apic_save
, apic_load
, s
);
962 qemu_register_reset(apic_reset
, 0, s
);
964 local_apics
[s
->idx
] = s
;