qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/8] ide: add save/restore support for isa
Date: Tue, 18 Aug 2009 18:06:42 +0200	[thread overview]
Message-ID: <1250611607-2441-4-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1250611607-2441-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/ide-internal.h |    5 +++++
 hw/ide-isa.c      |   33 +++++++++++++++++++++++++++++----
 hw/ide.c          |    8 ++++----
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/hw/ide-internal.h b/hw/ide-internal.h
index c2ccb11..d4a4947 100644
--- a/hw/ide-internal.h
+++ b/hw/ide-internal.h
@@ -90,6 +90,11 @@ static inline IDEState *idebus_active_if(IDEBus *bus)
 }
 
 /* ide.c */
+void ide_save(QEMUFile* f, IDEState *s);
+void ide_load(QEMUFile* f, IDEState *s, int version_id);
+void idebus_save(QEMUFile* f, IDEBus *bus);
+void idebus_load(QEMUFile* f, IDEBus *bus, int version_id);
+
 void ide_init2(IDEBus *bus, BlockDriverState *hd0, BlockDriverState *hd1,
                qemu_irq irq);
 void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
diff --git a/hw/ide-isa.c b/hw/ide-isa.c
index 2d65825..38ba6f9 100644
--- a/hw/ide-isa.c
+++ b/hw/ide-isa.c
@@ -33,13 +33,38 @@
 /***********************************************************/
 /* ISA IDE definitions */
 
+typedef struct ISAIDEState {
+    IDEBus *bus;
+} ISAIDEState;
+
+static void isa_ide_save(QEMUFile* f, void *opaque)
+{
+    ISAIDEState *s = opaque;
+
+    idebus_save(f, s->bus);
+    ide_save(f, &s->bus->ifs[0]);
+    ide_save(f, &s->bus->ifs[1]);
+}
+
+static int isa_ide_load(QEMUFile* f, void *opaque, int version_id)
+{
+    ISAIDEState *s = opaque;
+
+    idebus_load(f, s->bus, version_id);
+    ide_load(f, &s->bus->ifs[0], version_id);
+    ide_load(f, &s->bus->ifs[1], version_id);
+    return 0;
+}
+
 void isa_ide_init(int iobase, int iobase2, qemu_irq irq,
                   BlockDriverState *hd0, BlockDriverState *hd1)
 {
-    IDEBus *bus;
+    ISAIDEState *s;
 
-    bus = qemu_mallocz(sizeof(*bus));
+    s = qemu_mallocz(sizeof(*s));
+    s->bus = qemu_mallocz(sizeof(IDEBus));
 
-    ide_init2(bus, hd0, hd1, irq);
-    ide_init_ioport(bus, iobase, iobase2);
+    ide_init2(s->bus, hd0, hd1, irq);
+    ide_init_ioport(s->bus, iobase, iobase2);
+    register_savevm("isa-ide", 0, 3, isa_ide_save, isa_ide_load, s);
 }
diff --git a/hw/ide.c b/hw/ide.c
index 879196e..5fb42b7 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -2800,7 +2800,7 @@ void ide_init_ioport(IDEBus *bus, int iobase, int iobase2)
 }
 
 /* save per IDE drive data */
-static void ide_save(QEMUFile* f, IDEState *s)
+void ide_save(QEMUFile* f, IDEState *s)
 {
     qemu_put_be32(f, s->mult_sectors);
     qemu_put_be32(f, s->identify_set);
@@ -2829,7 +2829,7 @@ static void ide_save(QEMUFile* f, IDEState *s)
 }
 
 /* load per IDE drive data */
-static void ide_load(QEMUFile* f, IDEState *s, int version_id)
+void ide_load(QEMUFile* f, IDEState *s, int version_id)
 {
     s->mult_sectors=qemu_get_be32(f);
     s->identify_set=qemu_get_be32(f);
@@ -2863,14 +2863,14 @@ static void ide_load(QEMUFile* f, IDEState *s, int version_id)
     /* XXX: if a transfer is pending, we do not save it yet */
 }
 
-static void idebus_save(QEMUFile* f, IDEBus *bus)
+void idebus_save(QEMUFile* f, IDEBus *bus)
 {
     IDEState *s = idebus_active_if(bus);
     qemu_put_8s(f, &s->cmd);
     qemu_put_8s(f, &bus->unit);
 }
 
-static void idebus_load(QEMUFile* f, IDEBus *bus, int version_id)
+void idebus_load(QEMUFile* f, IDEBus *bus, int version_id)
 {
     IDEState *s;
     uint8_t cmd;
-- 
1.6.2.5

  parent reply	other threads:[~2009-08-18 16:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18 16:06 [Qemu-devel] [PATCH 0/8] ide: cleanup and splitting Gerd Hoffmann
2009-08-18 16:06 ` [Qemu-devel] [PATCH 1/8] ide: add IDEBus struct, cleanups Gerd Hoffmann
2009-08-19  9:49   ` [Qemu-devel] " Juan Quintela
2009-08-18 16:06 ` [Qemu-devel] [PATCH 2/8] ide: split away ide-isa.c Gerd Hoffmann
2009-08-19  9:53   ` [Qemu-devel] " Juan Quintela
2009-08-18 16:06 ` Gerd Hoffmann [this message]
2009-08-18 16:06 ` [Qemu-devel] [PATCH 4/8] ide: split away ide-pci.c Gerd Hoffmann
2009-08-18 16:06 ` [Qemu-devel] [PATCH 5/8] ide: split away ide-macio.c Gerd Hoffmann
     [not found]   ` <m34os4qfv2.fsf@neno.mitica>
2009-08-19 13:05     ` [Qemu-devel] " Gerd Hoffmann
2009-08-18 16:06 ` [Qemu-devel] [PATCH 6/8] ide: split away ide-mmio.c Gerd Hoffmann
2009-08-18 16:06 ` [Qemu-devel] [PATCH 7/8] ide: add save/restore support for mmio Gerd Hoffmann
2009-08-19 10:07   ` [Qemu-devel] " Juan Quintela
2009-08-18 16:06 ` [Qemu-devel] [PATCH 8/8] ide: split away ide-microdrive.c Gerd Hoffmann
2009-08-18 17:08 ` [Qemu-devel] [PATCH 0/8] ide: cleanup and splitting Avi Kivity
2009-08-19  6:37   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250611607-2441-4-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).