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