diff options
author | Juan Quintela <quintela@redhat.com> | 2009-09-29 22:49:02 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-05 09:32:42 -0500 |
commit | c4c38c8c72eb67d2ae4efa7c9ba077df30c6e537 (patch) | |
tree | 835df189ea92fc2eaa22d458d3a2915b7d222c5f /target-i386/machine.c | |
parent | 66e6d55b75c50f196d486fb3161b2432bd9afea1 (diff) |
x86: factor out cpu_pre_save()
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'target-i386/machine.c')
-rw-r--r-- | target-i386/machine.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/target-i386/machine.c b/target-i386/machine.c index 15a8c25a44..2a9bc0b08c 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -31,19 +31,13 @@ static void cpu_get_seg(QEMUFile *f, SegmentCache *dt) vmstate_load_state(f, &vmstate_segment, dt, vmstate_segment.version_id); } -void cpu_save(QEMUFile *f, void *opaque) +static void cpu_pre_save(void *opaque) { CPUState *env = opaque; int i, bit; cpu_synchronize_state(env); - for(i = 0; i < CPU_NB_REGS; i++) - qemu_put_betls(f, &env->regs[i]); - qemu_put_betls(f, &env->eip); - qemu_put_betls(f, &env->eflags); - qemu_put_be32s(f, &env->hflags); - /* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; env->fptag_vmstate = 0; @@ -51,15 +45,42 @@ void cpu_save(QEMUFile *f, void *opaque) env->fptag_vmstate |= ((!env->fptags[i]) << i); } - qemu_put_be16s(f, &env->fpuc); - qemu_put_be16s(f, &env->fpus_vmstate); - qemu_put_be16s(f, &env->fptag_vmstate); - #ifdef USE_X86LDOUBLE env->fpregs_format_vmstate = 0; #else env->fpregs_format_vmstate = 1; #endif + + /* There can only be one pending IRQ set in the bitmap at a time, so try + to find it and save its number instead (-1 for none). */ + env->pending_irq_vmstate = -1; + for (i = 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { + if (env->interrupt_bitmap[i]) { + bit = ctz64(env->interrupt_bitmap[i]); + env->pending_irq_vmstate = i * 64 + bit; + break; + } + } +} + +void cpu_save(QEMUFile *f, void *opaque) +{ + CPUState *env = opaque; + int i; + + cpu_pre_save(opaque); + + for(i = 0; i < CPU_NB_REGS; i++) + qemu_put_betls(f, &env->regs[i]); + qemu_put_betls(f, &env->eip); + qemu_put_betls(f, &env->eflags); + qemu_put_be32s(f, &env->hflags); + + /* FPU */ + qemu_put_be16s(f, &env->fpuc); + qemu_put_be16s(f, &env->fpus_vmstate); + qemu_put_be16s(f, &env->fptag_vmstate); + qemu_put_be16s(f, &env->fpregs_format_vmstate); for(i = 0; i < 8; i++) { @@ -146,16 +167,6 @@ void cpu_save(QEMUFile *f, void *opaque) /* KVM-related states */ - /* There can only be one pending IRQ set in the bitmap at a time, so try - to find it and save its number instead (-1 for none). */ - env->pending_irq_vmstate = -1; - for (i = 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) { - if (env->interrupt_bitmap[i]) { - bit = ctz64(env->interrupt_bitmap[i]); - env->pending_irq_vmstate = i * 64 + bit; - break; - } - } qemu_put_sbe32s(f, &env->pending_irq_vmstate); qemu_put_be32s(f, &env->mp_state); qemu_put_be64s(f, &env->tsc); |