[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] ia64: make buffered pio aware of save/restore.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1193042569 -3600
# Node ID c44d82f36665f0ac74e5591ffcdc548494c0ecb2
# Parent  d77da4c174f71de6bd9ab92f5dbc0041a7155533
ia64: make buffered pio aware of save/restore.
Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 tools/ioemu/hw/ide.c                 |   63 ++++++++++++++++++++++++++++++++---
 tools/ioemu/target-i386-dm/helper2.c |    1 
 tools/ioemu/vl.h                     |    3 +
 3 files changed, 62 insertions(+), 5 deletions(-)

diff -r d77da4c174f7 -r c44d82f36665 tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c      Mon Oct 22 09:41:25 2007 +0100
+++ b/tools/ioemu/hw/ide.c      Mon Oct 22 09:42:49 2007 +0100
@@ -431,16 +431,21 @@ buffered_pio_init(void)
 }
 
 static inline void
+__buffered_pio_flush(struct pio_buffer *piobuf, IDEState *s, uint32_t pointer)
+{
+    uint8_t *buf = (uint8_t *)buffered_pio_page + piobuf->page_offset;
+    memcpy(s->data_ptr, buf, pointer);
+    s->data_ptr += pointer;
+}
+
+static inline void
 buffered_pio_flush(struct pio_buffer *piobuf)
 {
     IDEState *s = piobuf->opaque;
     uint32_t pointer = piobuf->pointer;
 
-    if (s != NULL && pointer > 0) {
-        uint8_t *buf = (uint8_t *)buffered_pio_page + piobuf->page_offset;
-        memcpy(s->data_ptr, buf, pointer);
-        s->data_ptr += pointer;
-    }
+    if (s != NULL && pointer > 0)
+        __buffered_pio_flush(piobuf, s, pointer);
 }
 
 static inline void
@@ -500,6 +505,54 @@ buffered_pio_read(IDEState *s, uint32_t 
     piobuf->pointer = 0;
     piobuf->data_end = data_end;
     piobuf->opaque = NULL;
+}
+
+/*
+ * buffered pio reads are undone. It results in normal pio when the domain
+ * is restored.
+ * buffered pio writes are handled before saving domain.
+ * However currently pci_ide_save/load() just discards a pending transfer. XXX
+ */
+static void
+__handle_buffered_pio(struct pio_buffer *piobuf)
+{
+    IDEState *s = piobuf->opaque;
+    uint32_t pointer = piobuf->pointer;
+
+    
+    if (pointer == 0)
+        return;/* no buffered pio */
+
+    if (s != NULL) {
+        /* written data are pending in pio_buffer. process it */
+        __buffered_pio_flush(piobuf, s, pointer);
+    } else {
+        /* data are buffered for pio read in pio_buffer.
+         * undone buffering by buffered_pio_read()
+         */
+        if (pointer > s->data_ptr - s->io_buffer)
+            pointer = s->data_ptr - s->io_buffer;
+        s->data_ptr -= pointer;
+    }
+       
+    piobuf->pointer = 0;
+    piobuf->data_end = 0;
+    piobuf->opaque = NULL;
+}
+
+void
+handle_buffered_pio(void)
+{
+    struct pio_buffer *p1, *p2;
+
+    if (!buffered_pio_page)
+        return;
+
+    p1 = &buffered_pio_page->pio[PIO_BUFFER_IDE_PRIMARY];
+    p2 = &buffered_pio_page->pio[PIO_BUFFER_IDE_SECONDARY];
+
+    __handle_buffered_pio(p1);
+    __handle_buffered_pio(p2);
 }
 
 #else /* !__ia64__ */
diff -r d77da4c174f7 -r c44d82f36665 tools/ioemu/target-i386-dm/helper2.c
--- a/tools/ioemu/target-i386-dm/helper2.c      Mon Oct 22 09:41:25 2007 +0100
+++ b/tools/ioemu/target-i386-dm/helper2.c      Mon Oct 22 09:42:49 2007 +0100
@@ -635,6 +635,7 @@ int main_loop(void)
         fprintf(logfile, "device model saving state\n");
 
         /* Pull all outstanding ioreqs through the system */
+        handle_buffered_pio();
         handle_buffered_io(env);
         main_loop_wait(1); /* For the select() on events */
 
diff -r d77da4c174f7 -r c44d82f36665 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h  Mon Oct 22 09:41:25 2007 +0100
+++ b/tools/ioemu/vl.h  Mon Oct 22 09:42:49 2007 +0100
@@ -1494,8 +1494,11 @@ static inline void xc_domain_shutdown_ho
 {
        xc_ia64_save_to_nvram(xc_handle, domid);
 }
+
+void handle_buffered_pio(void);
 #else
 #define xc_domain_shutdown_hook(xc_handle, domid)      do {} while (0)
+#define handle_buffered_pio()                          do {} while (0)
 #endif
 
 #endif /* VL_H */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.