summary refs log tree commit diff stats
path: root/hw/i8254.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/i8254.c')
-rw-r--r--hw/i8254.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/hw/i8254.c b/hw/i8254.c
index 1eb4a1860f..6f05168274 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -434,27 +434,37 @@ static int pit_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-PITState *pit_init(int base, int irq)
+static void pit_reset(void *opaque)
 {
-    PITState *pit = &pit_state;
+    PITState *pit = opaque;
     PITChannelState *s;
     int i;
 
     for(i = 0;i < 3; i++) {
         s = &pit->channels[i];
-        if (i == 0) {
-            /* the timer 0 is connected to an IRQ */
-            s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-            s->irq = irq;
-        }
         s->mode = 3;
         s->gate = (i != 2);
         pit_load_count(s, 0);
     }
+}
+
+PITState *pit_init(int base, int irq)
+{
+    PITState *pit = &pit_state;
+    PITChannelState *s;
+
+    s = &pit->channels[0];
+    /* the timer 0 is connected to an IRQ */
+    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+    s->irq = irq;
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
+    qemu_register_reset(pit_reset, pit);
     register_ioport_write(base, 4, 1, pit_ioport_write, pit);
     register_ioport_read(base, 3, 1, pit_ioport_read, pit);
+
+    pit_reset(pit);
+
     return pit;
 }