Revision c4c38c8c target-i386/machine.c

b/target-i386/machine.c
31 31
    vmstate_load_state(f, &vmstate_segment, dt, vmstate_segment.version_id);
32 32
}
33 33

  
34
void cpu_save(QEMUFile *f, void *opaque)
34
static void cpu_pre_save(void *opaque)
35 35
{
36 36
    CPUState *env = opaque;
37 37
    int i, bit;
38 38

  
39 39
    cpu_synchronize_state(env);
40 40

  
41
    for(i = 0; i < CPU_NB_REGS; i++)
42
        qemu_put_betls(f, &env->regs[i]);
43
    qemu_put_betls(f, &env->eip);
44
    qemu_put_betls(f, &env->eflags);
45
    qemu_put_be32s(f, &env->hflags);
46

  
47 41
    /* FPU */
48 42
    env->fpus_vmstate = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11;
49 43
    env->fptag_vmstate = 0;
......
51 45
        env->fptag_vmstate |= ((!env->fptags[i]) << i);
52 46
    }
53 47

  
54
    qemu_put_be16s(f, &env->fpuc);
55
    qemu_put_be16s(f, &env->fpus_vmstate);
56
    qemu_put_be16s(f, &env->fptag_vmstate);
57

  
58 48
#ifdef USE_X86LDOUBLE
59 49
    env->fpregs_format_vmstate = 0;
60 50
#else
61 51
    env->fpregs_format_vmstate = 1;
62 52
#endif
53

  
54
    /* There can only be one pending IRQ set in the bitmap at a time, so try
55
       to find it and save its number instead (-1 for none). */
56
    env->pending_irq_vmstate = -1;
57
    for (i = 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) {
58
        if (env->interrupt_bitmap[i]) {
59
            bit = ctz64(env->interrupt_bitmap[i]);
60
            env->pending_irq_vmstate = i * 64 + bit;
61
            break;
62
        }
63
    }
64
}
65

  
66
void cpu_save(QEMUFile *f, void *opaque)
67
{
68
    CPUState *env = opaque;
69
    int i;
70

  
71
    cpu_pre_save(opaque);
72

  
73
    for(i = 0; i < CPU_NB_REGS; i++)
74
        qemu_put_betls(f, &env->regs[i]);
75
    qemu_put_betls(f, &env->eip);
76
    qemu_put_betls(f, &env->eflags);
77
    qemu_put_be32s(f, &env->hflags);
78

  
79
    /* FPU */
80
    qemu_put_be16s(f, &env->fpuc);
81
    qemu_put_be16s(f, &env->fpus_vmstate);
82
    qemu_put_be16s(f, &env->fptag_vmstate);
83

  
63 84
    qemu_put_be16s(f, &env->fpregs_format_vmstate);
64 85

  
65 86
    for(i = 0; i < 8; i++) {
......
146 167

  
147 168
    /* KVM-related states */
148 169

  
149
    /* There can only be one pending IRQ set in the bitmap at a time, so try
150
       to find it and save its number instead (-1 for none). */
151
    env->pending_irq_vmstate = -1;
152
    for (i = 0; i < ARRAY_SIZE(env->interrupt_bitmap); i++) {
153
        if (env->interrupt_bitmap[i]) {
154
            bit = ctz64(env->interrupt_bitmap[i]);
155
            env->pending_irq_vmstate = i * 64 + bit;
156
            break;
157
        }
158
    }
159 170
    qemu_put_sbe32s(f, &env->pending_irq_vmstate);
160 171
    qemu_put_be32s(f, &env->mp_state);
161 172
    qemu_put_be64s(f, &env->tsc);

Also available in: Unified diff