From patchwork Tue Mar 19 18:24:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 15433 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A2E5323E00 for ; Tue, 19 Mar 2013 18:24:35 +0000 (UTC) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by fiordland.canonical.com (Postfix) with ESMTP id 59998A18BF6 for ; Tue, 19 Mar 2013 18:24:35 +0000 (UTC) Received: by mail-vb0-f51.google.com with SMTP id fq11so533004vbb.10 for ; Tue, 19 Mar 2013 11:24:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=NB+chKZLdiaGRlZdrqjQlMxn6ULPvdhvlTFZMfL9pro=; b=I8sL+QLRpDSlo5c3V2UiVvpZSaeoT0XRG0uOsDtYHIG4xX4zI35eUdP/NTF++fT08R gfUXXm5tPvf6knYlF5GHJG0DGKUIck35oUAs4Wg3Laa4/Zc7aaBr00/R5MOCUrG1rL7N sWD5azfIRNSsg1+eDMm1k1Isl41UNVY32BVsXSw1CHgLj6j7WZPhgp9a16t8ySKKOdJe F5kX1Mc+U5UxoiRkmoBU+eef/O8ys7GgvakHckkDgtqhLMac/w2bRvR5fwwWdQ2IGqtV 1cqBL8If8Ae152846zlEGcN0Lexmk3JOVWpl6aVWiQtChu1yJp9vm6QDsfsnOjcIRubz 5x7g== X-Received: by 10.52.18.148 with SMTP id w20mr3350498vdd.8.1363717474755; Tue, 19 Mar 2013 11:24:34 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp121691veb; Tue, 19 Mar 2013 11:24:34 -0700 (PDT) X-Received: by 10.180.75.143 with SMTP id c15mr5288726wiw.18.1363717473425; Tue, 19 Mar 2013 11:24:33 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id fx4si693642wib.48.2013.03.19.11.24.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Mar 2013 11:24:33 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UI1D3-00084B-Pv; Tue, 19 Mar 2013 18:24:29 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori , Juan Quintela Subject: [PATCH 2/2] pflash_cfi01: Implement migration support Date: Tue, 19 Mar 2013 18:24:29 +0000 Message-Id: <1363717469-30980-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1363717469-30980-1-git-send-email-peter.maydell@linaro.org> References: <1363717469-30980-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmxc77eBy4SG8IxlIi6lx/eFuasAbtLCI6s0bOffXfycjKv3XM0UxvugnrKPC5Kvw6f1aQC Add a vmstate to pflash_cfi01, so that it can be live migrated. XXX this device is in pc, so does this break cross version migration??? Signed-off-by: Peter Maydell --- hw/pflash_cfi01.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 20d10b3..646dc79 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -67,7 +67,7 @@ struct pflash_t { uint64_t sector_len; uint8_t width; uint8_t be; - int wcycle; /* if 0, the flash is read normally */ + uint8_t wcycle; /* if 0, the flash is read normally */ int ro; uint8_t cmd; uint8_t status; @@ -77,7 +77,7 @@ struct pflash_t { uint16_t ident3; uint8_t cfi_len; uint8_t cfi_table[0x52]; - hwaddr counter; + uint64_t counter; unsigned int writeblock_size; QEMUTimer *timer; MemoryRegion mem; @@ -85,6 +85,19 @@ struct pflash_t { void *storage; }; +static const VMStateDescription vmstate_pflash = { + .name = "pflash_cfi01", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT8(wcycle, pflash_t), + VMSTATE_UINT8(cmd, pflash_t), + VMSTATE_UINT8(status, pflash_t), + VMSTATE_UINT64(counter, pflash_t), + VMSTATE_END_OF_LIST() + } +}; + static void pflash_timer (void *opaque) { pflash_t *pfl = opaque; @@ -223,7 +236,7 @@ static inline void pflash_data_write(pflash_t *pfl, hwaddr offset, uint8_t *p = pfl->storage; DPRINTF("%s: block write offset " TARGET_FMT_plx - " value %x counter " TARGET_FMT_plx "\n", + " value %x counter %016" PRIx64 "\n", __func__, offset, value, pfl->counter); switch (width) { case 1: @@ -701,6 +714,7 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data) k->init = pflash_cfi01_init; dc->props = pflash_cfi01_properties; + dc->vmsd = &vmstate_pflash; }