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