Patchwork [RFC,2/2] ahci: Add migration support for ICH9

login
register
mail settings
Submitter Andreas Färber
Date Dec. 23, 2011, 2:55 p.m.
Message ID <1324652151-4299-3-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/133065/
State New
Headers show

Comments

Andreas Färber - Dec. 23, 2011, 2:55 p.m.
Introduce generic vmstate_ahci and VMSTATE_AHCI macro.
Resolve name conflict and hook it up for ich9-ahci.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
---
 hw/ide/ahci.c |   41 +++++++++++++++++++++++++++++++++++++++++
 hw/ide/ahci.h |   10 ++++++++++
 hw/ide/ich.c  |   11 ++++++++---
 3 files changed, 59 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 51cb48b..7d1415b 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1213,3 +1213,44 @@  void ahci_reset(void *opaque)
         ahci_reset_port(&d->ahci, i);
     }
 }
+
+const VMStateDescription vmstate_ahci_device = {
+    .name = "ahci port",
+    .version_id = 1,
+    .fields = (VMStateField []) {
+        VMSTATE_IDE_BUS(port, AHCIDevice),
+        VMSTATE_UINT32(port_state, AHCIDevice),
+        VMSTATE_UINT32(finished, AHCIDevice),
+        VMSTATE_UINT32(port_regs.lst_addr, AHCIDevice),
+        VMSTATE_UINT32(port_regs.lst_addr_hi, AHCIDevice),
+        VMSTATE_UINT32(port_regs.fis_addr, AHCIDevice),
+        VMSTATE_UINT32(port_regs.fis_addr_hi, AHCIDevice),
+        VMSTATE_UINT32(port_regs.irq_stat, AHCIDevice),
+        VMSTATE_UINT32(port_regs.irq_mask, AHCIDevice),
+        VMSTATE_UINT32(port_regs.cmd, AHCIDevice),
+        VMSTATE_UINT32(port_regs.tfdata, AHCIDevice),
+        VMSTATE_UINT32(port_regs.sig, AHCIDevice),
+        VMSTATE_UINT32(port_regs.scr_stat, AHCIDevice),
+        VMSTATE_UINT32(port_regs.scr_ctl, AHCIDevice),
+        VMSTATE_UINT32(port_regs.scr_err, AHCIDevice),
+        VMSTATE_UINT32(port_regs.scr_act, AHCIDevice),
+        VMSTATE_UINT32(port_regs.cmd_issue, AHCIDevice),
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+const VMStateDescription vmstate_ahci = {
+    .name = "ahci",
+    .version_id = 1,
+    .fields = (VMStateField []) {
+        VMSTATE_STRUCT_ARRAY(dev, AHCIState, AHCI_MAX_PORTS, 0,
+                             vmstate_ahci_device, AHCIDevice),
+        VMSTATE_UINT32(control_regs.cap, AHCIState),
+        VMSTATE_UINT32(control_regs.ghc, AHCIState),
+        VMSTATE_UINT32(control_regs.irqstatus, AHCIState),
+        VMSTATE_UINT32(control_regs.impl, AHCIState),
+        VMSTATE_UINT32(control_regs.version, AHCIState),
+        VMSTATE_UINT32(idp_index, AHCIState),
+        VMSTATE_END_OF_LIST()
+    },
+};
diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index 4df7c2b..56ee621 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -306,6 +306,16 @@  typedef struct AHCIPCIState {
     AHCIState ahci;
 } AHCIPCIState;
 
+extern const VMStateDescription vmstate_ahci;
+
+#define VMSTATE_AHCI(_field, _state) {                               \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(AHCIState),                                 \
+    .vmsd       = &vmstate_ahci,                                     \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, AHCIState),   \
+}
+
 typedef struct NCQFrame {
     uint8_t fis_type;
     uint8_t c;
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 3f7510f..851b6a9 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -79,9 +79,14 @@ 
 #define ICH9_IDP_INDEX          0x10
 #define ICH9_IDP_INDEX_LOG2     0x04
 
-static const VMStateDescription vmstate_ahci = {
+static const VMStateDescription vmstate_ich9_ahci = {
     .name = "ahci",
-    .unmigratable = 1,
+    .version_id = 1,
+    .fields = (VMStateField []) {
+        VMSTATE_PCI_DEVICE(card, AHCIPCIState),
+        VMSTATE_AHCI(ahci, AHCIPCIState),
+        VMSTATE_END_OF_LIST()
+    },
 };
 
 static int pci_ich9_ahci_init(PCIDevice *dev)
@@ -151,7 +156,7 @@  static PCIDeviceInfo ich_ahci_info[] = {
         .qdev.name    = "ich9-ahci",
         .qdev.alias   = "ahci",
         .qdev.size    = sizeof(AHCIPCIState),
-        .qdev.vmsd    = &vmstate_ahci,
+        .qdev.vmsd    = &vmstate_ich9_ahci,
         .init         = pci_ich9_ahci_init,
         .exit         = pci_ich9_uninit,
         .config_write = pci_ich9_write_config,