]>
Commit | Line | Data |
---|---|---|
77f63e1d RH |
1 | /* |
2 | * Microblaze VMState for qemu. | |
3 | * | |
4 | * Copyright (c) 2020 Linaro, Ltd. | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
ee452036 | 9 | * version 2.1 of the License, or (at your option) any later version. |
77f63e1d RH |
10 | * |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #include "qemu/osdep.h" | |
21 | #include "cpu.h" | |
22 | #include "migration/cpu.h" | |
23 | ||
24 | ||
25 | static VMStateField vmstate_mmu_fields[] = { | |
26 | VMSTATE_UINT64_2DARRAY(rams, MicroBlazeMMU, 2, TLB_ENTRIES), | |
27 | VMSTATE_UINT8_ARRAY(tids, MicroBlazeMMU, TLB_ENTRIES), | |
28 | VMSTATE_UINT32_ARRAY(regs, MicroBlazeMMU, 3), | |
29 | VMSTATE_END_OF_LIST() | |
30 | }; | |
31 | ||
32 | static const VMStateDescription vmstate_mmu = { | |
33 | .name = "mmu", | |
34 | .version_id = 0, | |
35 | .minimum_version_id = 0, | |
36 | .fields = vmstate_mmu_fields, | |
37 | }; | |
38 | ||
39 | static int get_msr(QEMUFile *f, void *opaque, size_t size, | |
40 | const VMStateField *field) | |
41 | { | |
42 | CPUMBState *env = container_of(opaque, CPUMBState, msr); | |
43 | ||
44 | mb_cpu_write_msr(env, qemu_get_be32(f)); | |
45 | return 0; | |
46 | } | |
47 | ||
48 | static int put_msr(QEMUFile *f, void *opaque, size_t size, | |
3ddba9a9 | 49 | const VMStateField *field, JSONWriter *vmdesc) |
77f63e1d RH |
50 | { |
51 | CPUMBState *env = container_of(opaque, CPUMBState, msr); | |
52 | ||
53 | qemu_put_be32(f, mb_cpu_read_msr(env)); | |
54 | return 0; | |
55 | } | |
56 | ||
57 | static const VMStateInfo vmstate_msr = { | |
58 | .name = "msr", | |
59 | .get = get_msr, | |
60 | .put = put_msr, | |
61 | }; | |
62 | ||
63 | static VMStateField vmstate_env_fields[] = { | |
64 | VMSTATE_UINT32_ARRAY(regs, CPUMBState, 32), | |
65 | ||
66 | VMSTATE_UINT32(pc, CPUMBState), | |
67 | VMSTATE_SINGLE(msr, CPUMBState, 0, vmstate_msr, uint32_t), | |
68 | VMSTATE_UINT32(esr, CPUMBState), | |
69 | VMSTATE_UINT32(fsr, CPUMBState), | |
70 | VMSTATE_UINT32(btr, CPUMBState), | |
71 | VMSTATE_UINT32(edr, CPUMBState), | |
72 | VMSTATE_UINT32(slr, CPUMBState), | |
73 | VMSTATE_UINT32(shr, CPUMBState), | |
74 | VMSTATE_UINT64(ear, CPUMBState), | |
75 | ||
76 | VMSTATE_UINT32(btarget, CPUMBState), | |
77 | VMSTATE_UINT32(imm, CPUMBState), | |
78 | VMSTATE_UINT32(iflags, CPUMBState), | |
79 | ||
80 | VMSTATE_UINT32(res_val, CPUMBState), | |
81 | VMSTATE_UINTTL(res_addr, CPUMBState), | |
82 | ||
83 | VMSTATE_STRUCT(mmu, CPUMBState, 0, vmstate_mmu, MicroBlazeMMU), | |
84 | ||
85 | VMSTATE_END_OF_LIST() | |
86 | }; | |
87 | ||
88 | static const VMStateDescription vmstate_env = { | |
89 | .name = "env", | |
90 | .version_id = 0, | |
91 | .minimum_version_id = 0, | |
92 | .fields = vmstate_env_fields, | |
93 | }; | |
94 | ||
95 | static VMStateField vmstate_cpu_fields[] = { | |
96 | VMSTATE_CPU(), | |
97 | VMSTATE_STRUCT(env, MicroBlazeCPU, 1, vmstate_env, CPUMBState), | |
98 | VMSTATE_END_OF_LIST() | |
99 | }; | |
100 | ||
101 | const VMStateDescription vmstate_mb_cpu = { | |
102 | .name = "cpu", | |
103 | .version_id = 0, | |
104 | .minimum_version_id = 0, | |
105 | .fields = vmstate_cpu_fields, | |
106 | }; |