Only create as many per CPU timers as there are CPUs.
Index: hw/slavio_timer.c
===================================================================
RCS file: /sources/qemu/qemu/hw/slavio_timer.c,v
retrieving revision 1.21
diff -p -u -r1.21 slavio_timer.c
--- hw/slavio_timer.c   1 Dec 2007 15:58:22 -0000       1.21
+++ hw/slavio_timer.c   16 Dec 2007 22:53:33 -0000
@@ -61,6 +61,7 @@ typedef struct SLAVIO_TIMERState {
     struct SLAVIO_TIMERState *master;
     int slave_index;
     // system only
+    unsigned int num_slaves;
     struct SLAVIO_TIMERState *slave[MAX_CPUS];
     uint32_t slave_mode;
 } SLAVIO_TIMERState;
@@ -352,14 +353,16 @@ static SLAVIO_TIMERState *slavio_timer_i
 }
 
 void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
-                           qemu_irq *cpu_irqs)
+                           qemu_irq *cpu_irqs, unsigned int num_cpus)
 {
     SLAVIO_TIMERState *master;
     unsigned int i;
 
     master = slavio_timer_init(base + SYS_TIMER_OFFSET, master_irq, NULL, 0);
 
-    for (i = 0; i < MAX_CPUS; i++) {
+    master->num_slaves = num_cpus;
+
+    for (i = 0; i < master->num_slaves; i++) {
         master->slave[i] = slavio_timer_init(base + (target_phys_addr_t)
                                              CPU_TIMER_OFFSET(i),
                                              cpu_irqs[i], master, i);
Index: hw/sun4m.c
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.c,v
retrieving revision 1.69
diff -p -u -r1.69 sun4m.c
--- hw/sun4m.c  10 Dec 2007 20:00:11 -0000      1.69
+++ hw/sun4m.c  16 Dec 2007 22:53:33 -0000
@@ -436,7 +436,7 @@ static void sun4m_hw_init(const struct h
                         hwdef->nvram_size, 8);
 
     slavio_timer_init_all(hwdef->counter_base, slavio_irq[hwdef->clock1_irq],
-                          slavio_cpu_irq);
+                          slavio_cpu_irq, smp_cpus);
 
     slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[hwdef->ms_kb_irq],
                               nographic);
Index: hw/sun4m.h
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.h,v
retrieving revision 1.4
diff -p -u -r1.4 sun4m.h
--- hw/sun4m.h  9 Dec 2007 17:03:50 -0000       1.4
+++ hw/sun4m.h  16 Dec 2007 22:53:33 -0000
@@ -36,7 +36,7 @@ void slavio_irq_info(void *opaque);
 
 /* slavio_timer.c */
 void slavio_timer_init_all(target_phys_addr_t base, qemu_irq master_irq,
-                           qemu_irq *cpu_irqs);
+                           qemu_irq *cpu_irqs, unsigned int num_cpus);
 
 /* slavio_serial.c */
 SerialState *slavio_serial_init(target_phys_addr_t base, qemu_irq irq,

Reply via email to