qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [4721] CRIS: Add (untested) cpu-state save/load.
@ 2008-06-09 23:44 Edgar E. Iglesias
  2009-03-03 17:48 ` Stefan Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Edgar E. Iglesias @ 2008-06-09 23:44 UTC (permalink / raw)
  To: qemu-devel

Revision: 4721
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4721
Author:   edgar_igl
Date:     2008-06-09 23:44:20 +0000 (Mon, 09 Jun 2008)

Log Message:
-----------
CRIS: Add (untested) cpu-state save/load.

Modified Paths:
--------------
    trunk/hw/etraxfs.c
    trunk/target-cris/machine.c

Modified: trunk/hw/etraxfs.c
===================================================================
--- trunk/hw/etraxfs.c	2008-06-09 23:33:30 UTC (rev 4720)
+++ trunk/hw/etraxfs.c	2008-06-09 23:44:20 UTC (rev 4721)
@@ -67,7 +67,7 @@
         cpu_model = "crisv32";
     }
     env = cpu_init(cpu_model);
-/*    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */
+    register_savevm("cpu", 0, 1, cpu_save, cpu_load, env);
     qemu_register_reset(main_cpu_reset, env);
 
     /* allocate RAM */

Modified: trunk/target-cris/machine.c
===================================================================
--- trunk/target-cris/machine.c	2008-06-09 23:33:30 UTC (rev 4720)
+++ trunk/target-cris/machine.c	2008-06-09 23:44:20 UTC (rev 4721)
@@ -5,3 +5,91 @@
 {
     qemu_register_machine(&bareetraxfs_machine);
 }
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+    CPUCRISState *env = opaque;
+    int i;
+    int s;
+    int mmu;
+
+    for (i = 0; i < 16; i++)
+        qemu_put_be32(f, env->regs[i]);
+    for (i = 0; i < 16; i++)
+        qemu_put_be32(f, env->pregs[i]);
+
+    qemu_put_be32(f, env->pc);
+    qemu_put_be32(f, env->ksp);
+
+    qemu_put_be32(f, env->dslot);
+    qemu_put_be32(f, env->btaken);
+    qemu_put_be32(f, env->btarget);
+
+    qemu_put_be32(f, env->cc_op);
+    qemu_put_be32(f, env->cc_mask);
+    qemu_put_be32(f, env->cc_dest);
+    qemu_put_be32(f, env->cc_src);
+    qemu_put_be32(f, env->cc_result);
+    qemu_put_be32(f, env->cc_size);
+    qemu_put_be32(f, env->cc_x);
+
+    for (s = 0; s < 4; i++) {
+        for (i = 0; i < 16; i++)
+            qemu_put_be32(f, env->sregs[s][i]);
+    }
+
+    qemu_put_be32(f, env->mmu_rand_lfsr);
+    for (mmu = 0; mmu < 2; mmu++) {
+        for (s = 0; s < 4; i++) {
+            for (i = 0; i < 16; i++) {
+                qemu_put_be32(f, env->tlbsets[mmu][s][i].lo);
+                qemu_put_be32(f, env->tlbsets[mmu][s][i].hi);
+            }
+        }
+    }
+}
+
+int cpu_load(QEMUFile *f, void *opaque, int version_id)
+{
+	CPUCRISState *env = opaque;
+    int i;
+    int s;
+    int mmu;
+
+    for (i = 0; i < 16; i++)
+        env->regs[i] = qemu_get_be32(f);
+    for (i = 0; i < 16; i++)
+        env->pregs[i] = qemu_get_be32(f);
+
+    env->pc = qemu_get_be32(f);
+    env->ksp = qemu_get_be32(f);
+
+    env->dslot = qemu_get_be32(f);
+    env->btaken = qemu_get_be32(f);
+    env->btarget = qemu_get_be32(f);
+
+    env->cc_op = qemu_get_be32(f);
+    env->cc_mask = qemu_get_be32(f);
+    env->cc_dest = qemu_get_be32(f);
+    env->cc_src = qemu_get_be32(f);
+    env->cc_result = qemu_get_be32(f);
+    env->cc_size = qemu_get_be32(f);
+    env->cc_x = qemu_get_be32(f);
+
+    for (s = 0; s < 4; i++) {
+        for (i = 0; i < 16; i++)
+            env->sregs[s][i] = qemu_get_be32(f);
+    }
+
+    env->mmu_rand_lfsr = qemu_get_be32(f);
+    for (mmu = 0; mmu < 2; mmu++) {
+        for (s = 0; s < 4; i++) {
+            for (i = 0; i < 16; i++) {
+                env->tlbsets[mmu][s][i].lo = qemu_get_be32(f);
+                env->tlbsets[mmu][s][i].hi = qemu_get_be32(f);
+            }
+        }
+    }
+
+    return 0;
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [4721] CRIS: Add (untested) cpu-state save/load.
  2008-06-09 23:44 [Qemu-devel] [4721] CRIS: Add (untested) cpu-state save/load Edgar E. Iglesias
@ 2009-03-03 17:48 ` Stefan Weil
  2009-03-04  1:56   ` Edgar E. Iglesias
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2009-03-03 17:48 UTC (permalink / raw)
  To: qemu-devel, edgar.iglesias; +Cc: Anthony Liguori

[-- Attachment #1: Type: text/plain, Size: 643 bytes --]

Edgar E. Iglesias schrieb:
> Revision: 4721
> http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4721
> Author: edgar_igl
> Date: 2008-06-09 23:44:20 +0000 (Mon, 09 Jun 2008)
>
> Log Message:
> -----------
> CRIS: Add (untested) cpu-state save/load.
>
> Modified Paths:
> --------------
> trunk/hw/etraxfs.c
> trunk/target-cris/machine.c

It's indeed untested and even unused. Using compiler option
-Wmissing-noreturn I detected several endless loops.

The appended patch fixes them - please apply it to Qemu trunk.

Regards

Stefan Weil


PS. Antony, maybe such bugs might be a good reason to use
    the -Wmissing-noreturn option!




[-- Attachment #2: cris.patch --]
[-- Type: text/x-diff, Size: 1391 bytes --]

Fix several endless loops.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>

Index: target-cris/machine.c
===================================================================
--- target-cris/machine.c	(Revision 6676)
+++ target-cris/machine.c	(Arbeitskopie)
@@ -34,14 +34,14 @@
     qemu_put_be32(f, env->cc_size);
     qemu_put_be32(f, env->cc_x);
 
-    for (s = 0; s < 4; i++) {
+    for (s = 0; s < 4; s++) {
         for (i = 0; i < 16; i++)
             qemu_put_be32(f, env->sregs[s][i]);
     }
 
     qemu_put_be32(f, env->mmu_rand_lfsr);
     for (mmu = 0; mmu < 2; mmu++) {
-        for (s = 0; s < 4; i++) {
+        for (s = 0; s < 4; s++) {
             for (i = 0; i < 16; i++) {
                 qemu_put_be32(f, env->tlbsets[mmu][s][i].lo);
                 qemu_put_be32(f, env->tlbsets[mmu][s][i].hi);
@@ -77,14 +77,14 @@
     env->cc_size = qemu_get_be32(f);
     env->cc_x = qemu_get_be32(f);
 
-    for (s = 0; s < 4; i++) {
+    for (s = 0; s < 4; s++) {
         for (i = 0; i < 16; i++)
             env->sregs[s][i] = qemu_get_be32(f);
     }
 
     env->mmu_rand_lfsr = qemu_get_be32(f);
     for (mmu = 0; mmu < 2; mmu++) {
-        for (s = 0; s < 4; i++) {
+        for (s = 0; s < 4; s++) {
             for (i = 0; i < 16; i++) {
                 env->tlbsets[mmu][s][i].lo = qemu_get_be32(f);
                 env->tlbsets[mmu][s][i].hi = qemu_get_be32(f);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [4721] CRIS: Add (untested) cpu-state save/load.
  2009-03-03 17:48 ` Stefan Weil
@ 2009-03-04  1:56   ` Edgar E. Iglesias
  0 siblings, 0 replies; 3+ messages in thread
From: Edgar E. Iglesias @ 2009-03-04  1:56 UTC (permalink / raw)
  To: Stefan Weil; +Cc: edgar.iglesias, Anthony Liguori, qemu-devel

On Tue, Mar 03, 2009 at 06:48:24PM +0100, Stefan Weil wrote:
> Edgar E. Iglesias schrieb:
> > Revision: 4721
> > http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4721
> > Author: edgar_igl
> > Date: 2008-06-09 23:44:20 +0000 (Mon, 09 Jun 2008)
> >
> > Log Message:
> > -----------
> > CRIS: Add (untested) cpu-state save/load.
> >
> > Modified Paths:
> > --------------
> > trunk/hw/etraxfs.c
> > trunk/target-cris/machine.c
> 
> It's indeed untested and even unused. Using compiler option
> -Wmissing-noreturn I detected several endless loops.
> 
> The appended patch fixes them - please apply it to Qemu trunk.

Thanks, applied.

Cheers

> 
> Regards
> 
> Stefan Weil
> 
> 
> PS. Antony, maybe such bugs might be a good reason to use
>     the -Wmissing-noreturn option!
> 
> 
> 

> Fix several endless loops.
> 
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> 
> Index: target-cris/machine.c
> ===================================================================
> --- target-cris/machine.c	(Revision 6676)
> +++ target-cris/machine.c	(Arbeitskopie)
> @@ -34,14 +34,14 @@
>      qemu_put_be32(f, env->cc_size);
>      qemu_put_be32(f, env->cc_x);
>  
> -    for (s = 0; s < 4; i++) {
> +    for (s = 0; s < 4; s++) {
>          for (i = 0; i < 16; i++)
>              qemu_put_be32(f, env->sregs[s][i]);
>      }
>  
>      qemu_put_be32(f, env->mmu_rand_lfsr);
>      for (mmu = 0; mmu < 2; mmu++) {
> -        for (s = 0; s < 4; i++) {
> +        for (s = 0; s < 4; s++) {
>              for (i = 0; i < 16; i++) {
>                  qemu_put_be32(f, env->tlbsets[mmu][s][i].lo);
>                  qemu_put_be32(f, env->tlbsets[mmu][s][i].hi);
> @@ -77,14 +77,14 @@
>      env->cc_size = qemu_get_be32(f);
>      env->cc_x = qemu_get_be32(f);
>  
> -    for (s = 0; s < 4; i++) {
> +    for (s = 0; s < 4; s++) {
>          for (i = 0; i < 16; i++)
>              env->sregs[s][i] = qemu_get_be32(f);
>      }
>  
>      env->mmu_rand_lfsr = qemu_get_be32(f);
>      for (mmu = 0; mmu < 2; mmu++) {
> -        for (s = 0; s < 4; i++) {
> +        for (s = 0; s < 4; s++) {
>              for (i = 0; i < 16; i++) {
>                  env->tlbsets[mmu][s][i].lo = qemu_get_be32(f);
>                  env->tlbsets[mmu][s][i].hi = qemu_get_be32(f);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-03 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-09 23:44 [Qemu-devel] [4721] CRIS: Add (untested) cpu-state save/load Edgar E. Iglesias
2009-03-03 17:48 ` Stefan Weil
2009-03-04  1:56   ` Edgar E. Iglesias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).