4 * Copyright (c) 2016-2020 Michael Rolnik
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
9 * version 2.1 of the License, or (at your option) any later version.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/lgpl-2.1.html>
21 #include "qemu/osdep.h"
23 #include "migration/cpu.h"
25 static int get_sreg(QEMUFile
*f
, void *opaque
, size_t size
,
26 const VMStateField
*field
)
28 CPUAVRState
*env
= opaque
;
31 sreg
= qemu_get_byte(f
);
32 cpu_set_sreg(env
, sreg
);
36 static int put_sreg(QEMUFile
*f
, void *opaque
, size_t size
,
37 const VMStateField
*field
, JSONWriter
*vmdesc
)
39 CPUAVRState
*env
= opaque
;
40 uint8_t sreg
= cpu_get_sreg(env
);
42 qemu_put_byte(f
, sreg
);
46 static const VMStateInfo vms_sreg
= {
52 static int get_segment(QEMUFile
*f
, void *opaque
, size_t size
,
53 const VMStateField
*field
)
55 uint32_t *ramp
= opaque
;
58 temp
= qemu_get_byte(f
);
59 *ramp
= ((uint32_t)temp
) << 16;
63 static int put_segment(QEMUFile
*f
, void *opaque
, size_t size
,
64 const VMStateField
*field
, JSONWriter
*vmdesc
)
66 uint32_t *ramp
= opaque
;
67 uint8_t temp
= *ramp
>> 16;
69 qemu_put_byte(f
, temp
);
73 static const VMStateInfo vms_rampD
= {
78 static const VMStateInfo vms_rampX
= {
83 static const VMStateInfo vms_rampY
= {
88 static const VMStateInfo vms_rampZ
= {
93 static const VMStateInfo vms_eind
= {
99 const VMStateDescription vms_avr_cpu
= {
102 .minimum_version_id
= 1,
103 .fields
= (const VMStateField
[]) {
104 VMSTATE_UINT32(env
.pc_w
, AVRCPU
),
105 VMSTATE_UINT32(env
.sp
, AVRCPU
),
106 VMSTATE_UINT32(env
.skip
, AVRCPU
),
108 VMSTATE_UINT32_ARRAY(env
.r
, AVRCPU
, NUMBER_OF_CPU_REGISTERS
),
110 VMSTATE_SINGLE(env
, AVRCPU
, 0, vms_sreg
, CPUAVRState
),
111 VMSTATE_SINGLE(env
.rampD
, AVRCPU
, 0, vms_rampD
, uint32_t),
112 VMSTATE_SINGLE(env
.rampX
, AVRCPU
, 0, vms_rampX
, uint32_t),
113 VMSTATE_SINGLE(env
.rampY
, AVRCPU
, 0, vms_rampY
, uint32_t),
114 VMSTATE_SINGLE(env
.rampZ
, AVRCPU
, 0, vms_rampZ
, uint32_t),
115 VMSTATE_SINGLE(env
.eind
, AVRCPU
, 0, vms_eind
, uint32_t),
117 VMSTATE_END_OF_LIST()