From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCAep-0001gq-0l for qemu-devel@nongnu.org; Sun, 12 Jun 2016 15:02:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCAen-0000sD-Vp for qemu-devel@nongnu.org; Sun, 12 Jun 2016 15:02:50 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCAen-0000ry-L6 for qemu-devel@nongnu.org; Sun, 12 Jun 2016 15:02:49 -0400 Received: by mail-wm0-x243.google.com with SMTP id n184so10114567wmn.1 for ; Sun, 12 Jun 2016 12:02:49 -0700 (PDT) From: Michael Rolnik Date: Sun, 12 Jun 2016 22:01:50 +0300 Message-Id: <1465758111-60131-11-git-send-email-mrolnik@gmail.com> In-Reply-To: <1465758111-60131-1-git-send-email-mrolnik@gmail.com> References: <1465758111-60131-1-git-send-email-mrolnik@gmail.com> Subject: [Qemu-devel] [PATCH v6 10/11] target-avr: saving sreg, rampD, rampX, rampY, rampD, eind in HW representation saving cpu features List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: rth@twiddle.net, peter.maydell@linaro.org, Michael Rolnik From: Michael Rolnik Signed-off-by: Michael Rolnik --- target-avr/machine.c | 105 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 84 insertions(+), 21 deletions(-) diff --git a/target-avr/machine.c b/target-avr/machine.c index 39f1ee6..9659c04 100644 --- a/target-avr/machine.c +++ b/target-avr/machine.c @@ -23,31 +23,94 @@ #include "cpu.h" #include "hw/boards.h" #include "machine.h" +#include "migration/qemu-file.h" + +static int get_sreg(QEMUFile *f, void *opaque, size_t size) +{ + CPUAVRState* env = opaque; + uint8_t sreg; + + qemu_get_8s(f, &sreg); + cpu_set_sreg(env, sreg); + return 0; +} + +static void put_sreg(QEMUFile *f, void *opaque, size_t size) +{ + CPUAVRState* env = opaque; + uint8_t sreg = cpu_get_sreg(env); + + qemu_put_8s(f, &sreg); +} + +static const VMStateInfo vmstate_sreg = { + .name = "sreg", + .get = get_sreg, + .put = put_sreg, +}; + +static int get_segment(QEMUFile *f, void *opaque, size_t size) +{ + uint32_t *ramp = opaque; + uint8_t temp = *ramp >> 16; + + qemu_get_8s(f, &temp); + return 0; +} + +static void put_segment(QEMUFile *f, void *opaque, size_t size) +{ + uint32_t *ramp = opaque; + uint8_t temp; + + qemu_put_8s(f, &temp); + *ramp = ((uint32_t)temp) << 16; +} + +static const VMStateInfo vmstate_rampD = { + .name = "rampD", + .get = get_segment, + .put = put_segment, +}; +static const VMStateInfo vmstate_rampX = { + .name = "rampX", + .get = get_segment, + .put = put_segment, +}; +static const VMStateInfo vmstate_rampY = { + .name = "rampY", + .get = get_segment, + .put = put_segment, +}; +static const VMStateInfo vmstate_rampZ = { + .name = "rampZ", + .get = get_segment, + .put = put_segment, +}; +static const VMStateInfo vmstate_eind = { + .name = "eind", + .get = get_segment, + .put = put_segment, +}; const VMStateDescription vmstate_avr_cpu = { .name = "cpu", - .version_id = 1, - .minimum_version_id = 1, + .version_id = 0, + .minimum_version_id = 0, .fields = (VMStateField[]) { - VMSTATE_UINT32_ARRAY(r, CPUAVRState, 32), - - VMSTATE_UINT32(sregC, CPUAVRState), - VMSTATE_UINT32(sregZ, CPUAVRState), - VMSTATE_UINT32(sregN, CPUAVRState), - VMSTATE_UINT32(sregV, CPUAVRState), - VMSTATE_UINT32(sregS, CPUAVRState), - VMSTATE_UINT32(sregH, CPUAVRState), - VMSTATE_UINT32(sregT, CPUAVRState), - VMSTATE_UINT32(sregI, CPUAVRState), - - VMSTATE_UINT32(rampD, CPUAVRState), - VMSTATE_UINT32(rampX, CPUAVRState), - VMSTATE_UINT32(rampY, CPUAVRState), - VMSTATE_UINT32(rampZ, CPUAVRState), - - VMSTATE_UINT32(eind, CPUAVRState), - VMSTATE_UINT32(sp, CPUAVRState), - VMSTATE_UINT32(pc_w, CPUAVRState), + VMSTATE_UINT32(env.features, AVRCPU), + VMSTATE_UINT32(env.pc_w, AVRCPU), + VMSTATE_UINT32(env.sp, AVRCPU), + + VMSTATE_UINT32_ARRAY(env.r, AVRCPU, 32), + VMSTATE_UINT32_ARRAY(env.io, AVRCPU, 64), + + VMSTATE_SINGLE_TEST(env, AVRCPU, NULL, 0, vmstate_sreg, CPUAVRState), + VMSTATE_SINGLE_TEST(env.rampD, AVRCPU, NULL, 0, vmstate_rampD, uint32_t), + VMSTATE_SINGLE_TEST(env.rampX, AVRCPU, NULL, 0, vmstate_rampX, uint32_t), + VMSTATE_SINGLE_TEST(env.rampY, AVRCPU, NULL, 0, vmstate_rampY, uint32_t), + VMSTATE_SINGLE_TEST(env.rampZ, AVRCPU, NULL, 0, vmstate_rampZ, uint32_t), + VMSTATE_SINGLE_TEST(env.eind, AVRCPU, NULL, 0, vmstate_eind, uint32_t), VMSTATE_END_OF_LIST() } -- 2.4.9 (Apple Git-60)