From patchwork Sat Feb 2 23:40:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 217714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 31C3D2C0094 for ; Sun, 3 Feb 2013 10:53:23 +1100 (EST) Received: from localhost ([::1]:49029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1mi3-0003TC-2A for incoming@patchwork.ozlabs.org; Sat, 02 Feb 2013 18:41:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1mh9-0001SZ-9o for qemu-devel@nongnu.org; Sat, 02 Feb 2013 18:40:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1mh6-0000pW-PH for qemu-devel@nongnu.org; Sat, 02 Feb 2013 18:40:27 -0500 Received: from mail-wg0-f43.google.com ([74.125.82.43]:33950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1mh6-0000p6-HA for qemu-devel@nongnu.org; Sat, 02 Feb 2013 18:40:24 -0500 Received: by mail-wg0-f43.google.com with SMTP id e12so3834532wge.10 for ; Sat, 02 Feb 2013 15:40:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=nI7ihAvVrjiyV4DaHIEFdtF3AxcKcg1hSkp9CEHUbZw=; b=ESGzkh4FIjt+oTpvOeZGlMshBlTZhU8kd1f/Y9LrpeVZhofmu8hPPbA8L/iApzS+iT XgBSBefJNENu+3xTVZ8LlDDtzdt3cY1R/q+zoBDvJ9ZIgKSyfwaHlxUwB4Msng1qSH+1 TbRwKDyUNJyDGV7pW1nJJqOmfjeCgFZBjY17vhYudAhT2h7RZeeZIUo7LHerN6WIAy13 sIM/LxIS2foWodZ4pIT7p4B1VIkTG/LZ3SWgApJIENZ4r5AzQxLERDLcgLnEnD0abVDb N5VprQbC63bOH6cwcGGd4HsLdIUfTOKSb9vkueqtmP5Ot+GmAs1Pj4YQsYz32OWBTSIr TxMA== X-Received: by 10.180.84.131 with SMTP id z3mr3959460wiy.25.1359848423486; Sat, 02 Feb 2013 15:40:23 -0800 (PST) Received: from localhost (host86-136-235-200.range86-136.btcentralplus.com. [86.136.235.200]) by mx.google.com with ESMTPS id fx5sm12729409wib.11.2013.02.02.15.40.20 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Feb 2013 15:40:22 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id C260F3E1119; Sat, 2 Feb 2013 23:40:18 +0000 (GMT) From: Grant Likely To: qemu-devel@nongnu.org Date: Sat, 2 Feb 2013 23:40:08 +0000 Message-Id: <1359848409-1106-8-git-send-email-grant.likely@secretlab.ca> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359848409-1106-1-git-send-email-grant.likely@secretlab.ca> References: <1359848409-1106-1-git-send-email-grant.likely@secretlab.ca> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmPjC3Mpe92CnhHkjyg/B8RkJfKF+Y//bK1K+s4TEgY/h05243GVzsjXMwix0Z3LgpEWnCX X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.82.43 Cc: Peter Maydell , Anthony Liguori , Grant Likely , Paul Brook , "Edgar E. Iglesias" , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH V3 7/8] hw/mdio: Add VMState support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The MDIO model needs to have VMState support before it can be used by devices that support VMState. This patch adds VMState macros for both qemu_mdio and qemu_phy. Cc: Peter Maydell Cc: Paul Brook Cc: Edgar E. Iglesias Cc: Anthony Liguori Cc: Andreas Färber Signed-off-by: Grant Likely --- hw/mdio.c | 30 ++++++++++++++++++++++++++++++ hw/mdio.h | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/hw/mdio.c b/hw/mdio.c index 79f0e3b..023ad90 100644 --- a/hw/mdio.c +++ b/hw/mdio.c @@ -244,3 +244,33 @@ void mdio_bitbang_set_clk(struct qemu_mdio *bus, bool mdc) break; } } + +const VMStateDescription vmstate_mdio = { + .name = "mdio", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_BOOL(mdc, struct qemu_mdio), + VMSTATE_BOOL(mdio, struct qemu_mdio), + VMSTATE_UINT32(state, struct qemu_mdio), + VMSTATE_UINT16(cnt, struct qemu_mdio), + VMSTATE_UINT16(addr, struct qemu_mdio), + VMSTATE_UINT16(opc, struct qemu_mdio), + VMSTATE_UINT16(req, struct qemu_mdio), + VMSTATE_UINT32(shiftreg, struct qemu_mdio), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_mdio_phy = { + .name = "mdio", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT16_ARRAY(regs, struct qemu_phy, 32), + VMSTATE_BOOL(link, struct qemu_phy), + VMSTATE_END_OF_LIST() + } +}; diff --git a/hw/mdio.h b/hw/mdio.h index 340501e..62d292b 100644 --- a/hw/mdio.h +++ b/hw/mdio.h @@ -26,6 +26,7 @@ */ #include +#include "migration/vmstate.h" /* PHY MII Register/Bit Definitions */ /* PHY Registers defined by IEEE */ @@ -63,6 +64,16 @@ struct qemu_phy { void (*write)(struct qemu_phy *phy, unsigned int req, uint16_t data); }; +extern const VMStateDescription vmstate_mdio_phy; + +#define VMSTATE_MDIO_PHY(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(struct qemu_phy), \ + .vmsd = &vmstate_mdio_phy, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, struct qemu_phy), \ +} + struct qemu_mdio { /* bitbanging state machine */ bool mdc; @@ -85,6 +96,16 @@ struct qemu_mdio { struct qemu_phy *devs[32]; }; +extern const VMStateDescription vmstate_mdio; + +#define VMSTATE_MDIO(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(struct qemu_mdio), \ + .vmsd = &vmstate_mdio, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, struct qemu_mdio), \ +} + void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2); void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy, unsigned int addr);