ia64/xen-unstable

changeset 16183:c44d82f36665

ia64: make buffered pio aware of save/restore.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir@xensource.com>
date Mon Oct 22 09:42:49 2007 +0100 (2007-10-22)
parents d77da4c174f7
children 183a2d6eaadf
files tools/ioemu/hw/ide.c tools/ioemu/target-i386-dm/helper2.c tools/ioemu/vl.h
line diff
     1.1 --- a/tools/ioemu/hw/ide.c	Mon Oct 22 09:41:25 2007 +0100
     1.2 +++ b/tools/ioemu/hw/ide.c	Mon Oct 22 09:42:49 2007 +0100
     1.3 @@ -431,16 +431,21 @@ buffered_pio_init(void)
     1.4  }
     1.5  
     1.6  static inline void
     1.7 +__buffered_pio_flush(struct pio_buffer *piobuf, IDEState *s, uint32_t pointer)
     1.8 +{
     1.9 +    uint8_t *buf = (uint8_t *)buffered_pio_page + piobuf->page_offset;
    1.10 +    memcpy(s->data_ptr, buf, pointer);
    1.11 +    s->data_ptr += pointer;
    1.12 +}
    1.13 +
    1.14 +static inline void
    1.15  buffered_pio_flush(struct pio_buffer *piobuf)
    1.16  {
    1.17      IDEState *s = piobuf->opaque;
    1.18      uint32_t pointer = piobuf->pointer;
    1.19  
    1.20 -    if (s != NULL && pointer > 0) {
    1.21 -        uint8_t *buf = (uint8_t *)buffered_pio_page + piobuf->page_offset;
    1.22 -        memcpy(s->data_ptr, buf, pointer);
    1.23 -        s->data_ptr += pointer;
    1.24 -    }
    1.25 +    if (s != NULL && pointer > 0)
    1.26 +        __buffered_pio_flush(piobuf, s, pointer);
    1.27  }
    1.28  
    1.29  static inline void
    1.30 @@ -502,6 +507,54 @@ buffered_pio_read(IDEState *s, uint32_t 
    1.31      piobuf->opaque = NULL;
    1.32  }
    1.33  
    1.34 +/*
    1.35 + * buffered pio reads are undone. It results in normal pio when the domain
    1.36 + * is restored.
    1.37 + * buffered pio writes are handled before saving domain.
    1.38 + * However currently pci_ide_save/load() just discards a pending transfer. XXX
    1.39 + */
    1.40 +static void
    1.41 +__handle_buffered_pio(struct pio_buffer *piobuf)
    1.42 +{
    1.43 +    IDEState *s = piobuf->opaque;
    1.44 +    uint32_t pointer = piobuf->pointer;
    1.45 +
    1.46 +    
    1.47 +    if (pointer == 0)
    1.48 +        return;/* no buffered pio */
    1.49 +
    1.50 +    if (s != NULL) {
    1.51 +        /* written data are pending in pio_buffer. process it */
    1.52 +        __buffered_pio_flush(piobuf, s, pointer);
    1.53 +    } else {
    1.54 +        /* data are buffered for pio read in pio_buffer.
    1.55 +         * undone buffering by buffered_pio_read()
    1.56 +         */
    1.57 +        if (pointer > s->data_ptr - s->io_buffer)
    1.58 +            pointer = s->data_ptr - s->io_buffer;
    1.59 +        s->data_ptr -= pointer;
    1.60 +    }
    1.61 +	
    1.62 +    piobuf->pointer = 0;
    1.63 +    piobuf->data_end = 0;
    1.64 +    piobuf->opaque = NULL;
    1.65 +}
    1.66 +
    1.67 +void
    1.68 +handle_buffered_pio(void)
    1.69 +{
    1.70 +    struct pio_buffer *p1, *p2;
    1.71 +
    1.72 +    if (!buffered_pio_page)
    1.73 +        return;
    1.74 +
    1.75 +    p1 = &buffered_pio_page->pio[PIO_BUFFER_IDE_PRIMARY];
    1.76 +    p2 = &buffered_pio_page->pio[PIO_BUFFER_IDE_SECONDARY];
    1.77 +
    1.78 +    __handle_buffered_pio(p1);
    1.79 +    __handle_buffered_pio(p2);
    1.80 +}
    1.81 +
    1.82  #else /* !__ia64__ */
    1.83  #define buffered_pio_init()         do {} while (0)
    1.84  #define buffered_pio_reset(I)       do {} while (0)
     2.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Mon Oct 22 09:41:25 2007 +0100
     2.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Mon Oct 22 09:42:49 2007 +0100
     2.3 @@ -635,6 +635,7 @@ int main_loop(void)
     2.4          fprintf(logfile, "device model saving state\n");
     2.5  
     2.6          /* Pull all outstanding ioreqs through the system */
     2.7 +        handle_buffered_pio();
     2.8          handle_buffered_io(env);
     2.9          main_loop_wait(1); /* For the select() on events */
    2.10  
     3.1 --- a/tools/ioemu/vl.h	Mon Oct 22 09:41:25 2007 +0100
     3.2 +++ b/tools/ioemu/vl.h	Mon Oct 22 09:42:49 2007 +0100
     3.3 @@ -1494,8 +1494,11 @@ static inline void xc_domain_shutdown_ho
     3.4  {
     3.5  	xc_ia64_save_to_nvram(xc_handle, domid);
     3.6  }
     3.7 +
     3.8 +void handle_buffered_pio(void);
     3.9  #else
    3.10  #define xc_domain_shutdown_hook(xc_handle, domid)	do {} while (0)
    3.11 +#define handle_buffered_pio()				do {} while (0)
    3.12  #endif
    3.13  
    3.14  #endif /* VL_H */