| 1 | #include "qemu/osdep.h" |
| 2 | #include "cpu.h" |
| 3 | #include "migration/qemu-file-types.h" |
| 4 | #include "migration/vmstate.h" |
| 5 | |
| 6 | static int get_fpcr(QEMUFile *f, void *opaque, size_t size, |
| 7 | const VMStateField *field) |
| 8 | { |
| 9 | CPUAlphaState *env = opaque; |
| 10 | cpu_alpha_store_fpcr(env, qemu_get_be64(f)); |
| 11 | return 0; |
| 12 | } |
| 13 | |
| 14 | static int put_fpcr(QEMUFile *f, void *opaque, size_t size, |
| 15 | const VMStateField *field, JSONWriter *vmdesc) |
| 16 | { |
| 17 | CPUAlphaState *env = opaque; |
| 18 | qemu_put_be64(f, cpu_alpha_load_fpcr(env)); |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static const VMStateInfo vmstate_fpcr = { |
| 23 | .name = "fpcr", |
| 24 | .get = get_fpcr, |
| 25 | .put = put_fpcr, |
| 26 | }; |
| 27 | |
| 28 | static const VMStateField vmstate_env_fields[] = { |
| 29 | VMSTATE_UINT64_ARRAY(ir, CPUAlphaState, 31), |
| 30 | VMSTATE_UINT64_ARRAY(fir, CPUAlphaState, 31), |
| 31 | /* Save the architecture value of the fpcr, not the internally |
| 32 | expanded version. Since this architecture value does not |
| 33 | exist in memory to be stored, this requires a but of hoop |
| 34 | jumping. We want OFFSET=0 so that we effectively pass ENV |
| 35 | to the helper functions, and we need to fill in the name by |
| 36 | hand since there's no field of that name. */ |
| 37 | { |
| 38 | .name = "fpcr", |
| 39 | .version_id = 0, |
| 40 | .size = sizeof(uint64_t), |
| 41 | .info = &vmstate_fpcr, |
| 42 | .flags = VMS_SINGLE, |
| 43 | .offset = 0 |
| 44 | }, |
| 45 | VMSTATE_UINT64(pc, CPUAlphaState), |
| 46 | VMSTATE_UINT64(unique, CPUAlphaState), |
| 47 | VMSTATE_UINT64(lock_addr, CPUAlphaState), |
| 48 | VMSTATE_UINT64(lock_value, CPUAlphaState), |
| 49 | |
| 50 | VMSTATE_UINT32(flags, CPUAlphaState), |
| 51 | VMSTATE_UINT32(pcc_ofs, CPUAlphaState), |
| 52 | |
| 53 | VMSTATE_UINT64(trap_arg0, CPUAlphaState), |
| 54 | VMSTATE_UINT64(trap_arg1, CPUAlphaState), |
| 55 | VMSTATE_UINT64(trap_arg2, CPUAlphaState), |
| 56 | |
| 57 | VMSTATE_UINT64(exc_addr, CPUAlphaState), |
| 58 | VMSTATE_UINT64(palbr, CPUAlphaState), |
| 59 | VMSTATE_UINT64(ptbr, CPUAlphaState), |
| 60 | VMSTATE_UINT64(vptptr, CPUAlphaState), |
| 61 | VMSTATE_UINT64(sysval, CPUAlphaState), |
| 62 | VMSTATE_UINT64(usp, CPUAlphaState), |
| 63 | |
| 64 | VMSTATE_UINT64_ARRAY(shadow, CPUAlphaState, 8), |
| 65 | VMSTATE_UINT64_ARRAY(scratch, CPUAlphaState, 24), |
| 66 | |
| 67 | VMSTATE_END_OF_LIST() |
| 68 | }; |
| 69 | |
| 70 | static const VMStateDescription vmstate_env = { |
| 71 | .name = "env", |
| 72 | .version_id = 3, |
| 73 | .minimum_version_id = 3, |
| 74 | .fields = vmstate_env_fields, |
| 75 | }; |
| 76 | |
| 77 | static const VMStateField vmstate_cpu_fields[] = { |
| 78 | VMSTATE_STRUCT(parent_obj, AlphaCPU, 0, vmstate_cpu_common, CPUState), |
| 79 | VMSTATE_STRUCT(env, AlphaCPU, 1, vmstate_env, CPUAlphaState), |
| 80 | VMSTATE_END_OF_LIST() |
| 81 | }; |
| 82 | |
| 83 | const VMStateDescription vmstate_alpha_cpu = { |
| 84 | .name = "cpu", |
| 85 | .version_id = 1, |
| 86 | .minimum_version_id = 1, |
| 87 | .fields = vmstate_cpu_fields, |
| 88 | }; |