Skip to contentSkip to conversation

[4824] Save/restore for stellaris boards.

Qemu-devel Paul Brook 1 participant 1 message Jul 2, 2008

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

Revision: 4824

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4824
Author:   pbrook
Date:     2008-07-02 16:48:32 +0000 (Wed, 02 Jul 2008)

Log Message:
-----------
Save/restore for stellaris boards.

Modified Paths:
--------------

    trunk/hw/arm_gic.c
    trunk/hw/arm_timer.c
    trunk/hw/armv7m_nvic.c
    trunk/hw/pl011.c
    trunk/hw/pl022.c
    trunk/hw/pl061.c
    trunk/hw/ssd0303.c
    trunk/hw/ssd0323.c
    trunk/hw/ssi-sd.c
    trunk/hw/stellaris.c
    trunk/hw/stellaris_enet.c
    trunk/hw/stellaris_input.c

Modified: trunk/hw/arm_gic.c
===================================================================

hw/arm_gic.c +74 -0
@@ -650,6 +650,79 @@
 #endif
 }
 
+static void gic_save(QEMUFile *f, void *opaque)
+{
+    gic_state *s = (gic_state *)opaque;
+    int i;
+    int j;
+
+    qemu_put_be32(f, s->enabled);
+    for (i = 0; i < NCPU; i++) {
+        qemu_put_be32(f, s->cpu_enabled[i]);
+#ifndef NVIC
+        qemu_put_be32(f, s->irq_target[i]);
+#endif
+        for (j = 0; j < 32; j++)
+            qemu_put_be32(f, s->priority1[j][i]);
+        for (j = 0; j < GIC_NIRQ; j++)
+            qemu_put_be32(f, s->last_active[j][i]);
+        qemu_put_be32(f, s->priority_mask[i]);
+        qemu_put_be32(f, s->running_irq[i]);
+        qemu_put_be32(f, s->running_priority[i]);
+        qemu_put_be32(f, s->current_pending[i]);
+    }
+    for (i = 0; i < GIC_NIRQ - 32; i++) {
+        qemu_put_be32(f, s->priority2[i]);
+    }
+    for (i = 0; i < GIC_NIRQ; i++) {
+        qemu_put_byte(f, s->irq_state[i].enabled);
+        qemu_put_byte(f, s->irq_state[i].pending);
+        qemu_put_byte(f, s->irq_state[i].active);
+        qemu_put_byte(f, s->irq_state[i].level);
+        qemu_put_byte(f, s->irq_state[i].model);
+        qemu_put_byte(f, s->irq_state[i].trigger);
+    }
+}
+
+static int gic_load(QEMUFile *f, void *opaque, int version_id)
+{
+    gic_state *s = (gic_state *)opaque;
+    int i;
+    int j;
+
+    if (version_id != 1)
+        return -EINVAL;
+
+    s->enabled = qemu_get_be32(f);
+    for (i = 0; i < NCPU; i++) {
+        s->cpu_enabled[i] = qemu_get_be32(f);
+#ifndef NVIC
+        s->irq_target[i] = qemu_get_be32(f);
+#endif
+        for (j = 0; j < 32; j++)
+            s->priority1[j][i] = qemu_get_be32(f);
+        for (j = 0; j < GIC_NIRQ; j++)
+            s->last_active[j][i] = qemu_get_be32(f);
+        s->priority_mask[i] = qemu_get_be32(f);
+        s->running_irq[i] = qemu_get_be32(f);
+        s->running_priority[i] = qemu_get_be32(f);
+        s->current_pending[i] = qemu_get_be32(f);
+    }
+    for (i = 0; i < GIC_NIRQ - 32; i++) {
+        s->priority2[i] = qemu_get_be32(f);
+    }
+    for (i = 0; i < GIC_NIRQ; i++) {
+        s->irq_state[i].enabled = qemu_get_byte(f);
+        s->irq_state[i].pending = qemu_get_byte(f);
+        s->irq_state[i].active = qemu_get_byte(f);
+        s->irq_state[i].level = qemu_get_byte(f);
+        s->irq_state[i].model = qemu_get_byte(f);
+        s->irq_state[i].trigger = qemu_get_byte(f);
+    }
+
+    return 0;
+}
+
 static gic_state *gic_init(uint32_t base, qemu_irq *parent_irq)
 {
     gic_state *s;
@@ -669,5 +742,6 @@
                                  iomemtype);
     s->base = base;
     gic_reset(s);
+    register_savevm("arm_gic", -1, 1, gic_save, gic_load, s);
     return s;
 }

Modified: trunk/hw/arm_timer.c
===================================================================

hw/arm_timer.c +46 -3

78 lines not on this page · raw message

Modified: trunk/hw/armv7m_nvic.c
===================================================================

hw/armv7m_nvic.c +26 -0
@@ -368,6 +368,31 @@
     }
 }
 
+static void nvic_save(QEMUFile *f, void *opaque)
+{
+    nvic_state *s = (nvic_state *)opaque;
+
+    qemu_put_be32(f, s->systick.control);
+    qemu_put_be32(f, s->systick.reload);
+    qemu_put_be64(f, s->systick.tick);
+    qemu_put_timer(f, s->systick.timer);
+}
+
+static int nvic_load(QEMUFile *f, void *opaque, int version_id)
+{
+    nvic_state *s = (nvic_state *)opaque;
+
+    if (version_id != 1)
+        return -EINVAL;
+
+    s->systick.control = qemu_get_be32(f);
+    s->systick.reload = qemu_get_be32(f);
+    s->systick.tick = qemu_get_be64(f);
+    qemu_get_timer(f, s->systick.timer);
+
+    return 0;
+}
+
 qemu_irq *armv7m_nvic_init(CPUState *env)
 {
     nvic_state *s;
@@ -381,5 +406,6 @@
     if (env->v7m.nvic)
         cpu_abort(env, "CPU can only have one NVIC\n");
     env->v7m.nvic = s;
+    register_savevm("armv7m_nvic", -1, 1, nvic_save, nvic_load, s);
     return s->gic->in;
 }

Modified: trunk/hw/pl011.c
===================================================================

hw/pl011.c +52 -1

64 lines not on this page · raw message

Modified: trunk/hw/pl022.c
===================================================================

hw/pl022.c +50 -1

63 lines not on this page · raw message

Modified: trunk/hw/pl061.c
===================================================================

hw/pl061.c +57 -1

70 lines not on this page · raw message

Modified: trunk/hw/ssd0303.c
===================================================================

hw/ssd0303.c +44 -0

54 lines not on this page · raw message

Modified: trunk/hw/ssd0323.c
===================================================================

hw/ssd0323.c +49 -0

60 lines not on this page · raw message

Modified: trunk/hw/ssi-sd.c
===================================================================

hw/ssi-sd.c +38 -0
@@ -190,6 +190,43 @@
     return 0xff;
 }
 
+static void ssi_sd_save(QEMUFile *f, void *opaque)
+{
+    ssi_sd_state *s = (ssi_sd_state *)opaque;
+    int i;
+
+    qemu_put_be32(f, s->mode);
+    qemu_put_be32(f, s->cmd);
+    for (i = 0; i < 4; i++)
+        qemu_put_be32(f, s->cmdarg[i]);
+    for (i = 0; i < 5; i++)
+        qemu_put_be32(f, s->response[i]);
+    qemu_put_be32(f, s->arglen);
+    qemu_put_be32(f, s->response_pos);
+    qemu_put_be32(f, s->stopping);
+}
+
+static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)
+{
+    ssi_sd_state *s = (ssi_sd_state *)opaque;
+    int i;
+
+    if (version_id != 1)
+        return -EINVAL;
+
+    s->mode = qemu_get_be32(f);
+    s->cmd = qemu_get_be32(f);
+    for (i = 0; i < 4; i++)
+        s->cmdarg[i] = qemu_get_be32(f);
+    for (i = 0; i < 5; i++)
+        s->response[i] = qemu_get_be32(f);
+    s->arglen = qemu_get_be32(f);
+    s->response_pos = qemu_get_be32(f);
+    s->stopping = qemu_get_be32(f);
+
+    return 0;
+}
+
 void *ssi_sd_init(BlockDriverState *bs)
 {
     ssi_sd_state *s;
@@ -197,6 +234,7 @@
     s = (ssi_sd_state *)qemu_mallocz(sizeof(ssi_sd_state));
     s->mode = SSI_SD_CMD;
     s->sd = sd_init(bs, 1);
+    register_savevm("ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s);
     return s;
 }
 

Modified: trunk/hw/stellaris.c
===================================================================

hw/stellaris.c +235 -8

333 lines not on this page · raw message

Modified: trunk/hw/stellaris_enet.c
===================================================================

hw/stellaris_enet.c +63 -0

73 lines not on this page · raw message

Modified: trunk/hw/stellaris_input.c
===================================================================

hw/stellaris_input.c +27 -0
@@ -47,6 +47,31 @@
     s->extension = 0;
 }
 
+static void stellaris_gamepad_save(QEMUFile *f, void *opaque)
+{
+    gamepad_state *s = (gamepad_state *)opaque;
+    int i;
+
+    qemu_put_be32(f, s->extension);
+    for (i = 0; i < s->num_buttons; i++)
+        qemu_put_byte(f, s->buttons[i].pressed);
+}
+
+static int stellaris_gamepad_load(QEMUFile *f, void *opaque, int version_id)
+{
+    gamepad_state *s = (gamepad_state *)opaque;
+    int i;
+
+    if (version_id != 1)
+        return -EINVAL;
+
+    s->extension = qemu_get_be32(f);
+    for (i = 0; i < s->num_buttons; i++)
+        s->buttons[i].pressed = qemu_get_byte(f);
+
+    return 0;
+}
+
 /* Returns an array 5 ouput slots.  */
 void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
 {
@@ -61,6 +86,8 @@
     }
     s->num_buttons = n;
     qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);
+    register_savevm("stellaris_gamepad", -1, 1,
+                    stellaris_gamepad_save, stellaris_gamepad_load, s);
 }