direct-io.hg

changeset 10994:01043d543878

[qemu patches] Update patches for changeset 10993:dc7b56b8cfb5.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author chris@kneesaa.uk.xensource.com
date Wed Aug 09 11:25:55 2006 +0100 (2006-08-09)
parents dc7b56b8cfb5
children b16252dbcb1f
files tools/ioemu/patches/series tools/ioemu/patches/xen-support-buffered-ioreqs
line diff
     1.1 --- a/tools/ioemu/patches/series	Wed Aug 09 11:25:33 2006 +0100
     1.2 +++ b/tools/ioemu/patches/series	Wed Aug 09 11:25:55 2006 +0100
     1.3 @@ -39,3 +39,4 @@ xenstore-write-vnc-port
     1.4  qemu-allow-disable-sdl
     1.5  qemu-fix-memset-args
     1.6  qemu-fix-write-to-disk-synchronous
     1.7 +xen-support-buffered-ioreqs
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/ioemu/patches/xen-support-buffered-ioreqs	Wed Aug 09 11:25:55 2006 +0100
     2.3 @@ -0,0 +1,150 @@
     2.4 +Index: ioemu/vl.c
     2.5 +===================================================================
     2.6 +--- ioemu.orig/vl.c	2006-08-08 14:33:30.000000000 +0100
     2.7 ++++ ioemu/vl.c	2006-08-08 14:43:34.000000000 +0100
     2.8 +@@ -5834,6 +5834,7 @@
     2.9 +     unsigned long nr_pages;
    2.10 +     xen_pfn_t *page_array;
    2.11 +     extern void *shared_page;
    2.12 ++    extern void *buffered_io_page;
    2.13 + 
    2.14 +     char qemu_dm_logfilename[64];
    2.15 + 
    2.16 +@@ -6378,12 +6379,17 @@
    2.17 + 
    2.18 +     phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
    2.19 +                                          PROT_READ|PROT_WRITE, page_array,
    2.20 +-                                         nr_pages - 1);
    2.21 ++                                         nr_pages - 3);
    2.22 +     if (phys_ram_base == 0) {
    2.23 +         fprintf(logfile, "xc_map_foreign_batch returned error %d\n", errno);
    2.24 +         exit(-1);
    2.25 +     }
    2.26 + 
    2.27 ++    /* not yet add for IA64 */
    2.28 ++    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
    2.29 ++                                       PROT_READ|PROT_WRITE,
    2.30 ++                                       page_array[nr_pages - 3]);
    2.31 ++
    2.32 +     shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
    2.33 +                                        PROT_READ|PROT_WRITE,
    2.34 +                                        page_array[nr_pages - 1]);
    2.35 +Index: ioemu/target-i386-dm/helper2.c
    2.36 +===================================================================
    2.37 +--- ioemu.orig/target-i386-dm/helper2.c	2006-08-08 14:33:30.000000000 +0100
    2.38 ++++ ioemu/target-i386-dm/helper2.c	2006-08-09 10:03:40.558744653 +0100
    2.39 +@@ -76,6 +76,10 @@
    2.40 + 
    2.41 + shared_iopage_t *shared_page = NULL;
    2.42 + 
    2.43 ++#define BUFFER_IO_MAX_DELAY  100
    2.44 ++buffered_iopage_t *buffered_io_page = NULL;
    2.45 ++QEMUTimer *buffered_io_timer;
    2.46 ++
    2.47 + /* the evtchn fd for polling */
    2.48 + int xce_handle = -1;
    2.49 + 
    2.50 +@@ -419,36 +423,68 @@
    2.51 +     req->u.data = tmp1;
    2.52 + }
    2.53 + 
    2.54 ++void __handle_ioreq(CPUState *env, ioreq_t *req)
    2.55 ++{
    2.56 ++    if (!req->pdata_valid && req->dir == IOREQ_WRITE && req->size != 4)
    2.57 ++	req->u.data &= (1UL << (8 * req->size)) - 1;
    2.58 ++
    2.59 ++    switch (req->type) {
    2.60 ++    case IOREQ_TYPE_PIO:
    2.61 ++        cpu_ioreq_pio(env, req);
    2.62 ++        break;
    2.63 ++    case IOREQ_TYPE_COPY:
    2.64 ++        cpu_ioreq_move(env, req);
    2.65 ++        break;
    2.66 ++    case IOREQ_TYPE_AND:
    2.67 ++        cpu_ioreq_and(env, req);
    2.68 ++        break;
    2.69 ++    case IOREQ_TYPE_OR:
    2.70 ++        cpu_ioreq_or(env, req);
    2.71 ++        break;
    2.72 ++    case IOREQ_TYPE_XOR:
    2.73 ++        cpu_ioreq_xor(env, req);
    2.74 ++        break;
    2.75 ++    default:
    2.76 ++        hw_error("Invalid ioreq type 0x%x\n", req->type);
    2.77 ++    }
    2.78 ++}
    2.79 ++
    2.80 ++void __handle_buffered_iopage(CPUState *env)
    2.81 ++{
    2.82 ++    ioreq_t *req = NULL;
    2.83 ++
    2.84 ++    if (!buffered_io_page)
    2.85 ++        return;
    2.86 ++
    2.87 ++    while (buffered_io_page->read_pointer !=
    2.88 ++           buffered_io_page->write_pointer) {
    2.89 ++        req = &buffered_io_page->ioreq[buffered_io_page->read_pointer %
    2.90 ++				       IOREQ_BUFFER_SLOT_NUM];
    2.91 ++
    2.92 ++        __handle_ioreq(env, req);
    2.93 ++
    2.94 ++        mb();
    2.95 ++        buffered_io_page->read_pointer++;
    2.96 ++    }
    2.97 ++}
    2.98 ++
    2.99 ++void handle_buffered_io(void *opaque)
   2.100 ++{
   2.101 ++    CPUState *env = opaque;
   2.102 ++
   2.103 ++    __handle_buffered_iopage(env);
   2.104 ++    qemu_mod_timer(buffered_io_timer, BUFFER_IO_MAX_DELAY +
   2.105 ++		   qemu_get_clock(rt_clock));
   2.106 ++}
   2.107 ++
   2.108 + void cpu_handle_ioreq(void *opaque)
   2.109 + {
   2.110 +     CPUState *env = opaque;
   2.111 +     ioreq_t *req = cpu_get_ioreq();
   2.112 + 
   2.113 ++    handle_buffered_io(env);
   2.114 +     if (req) {
   2.115 +-        if ((!req->pdata_valid) && (req->dir == IOREQ_WRITE)) {
   2.116 +-            if (req->size != 4)
   2.117 +-                req->u.data &= (1UL << (8 * req->size))-1;
   2.118 +-        }
   2.119 +-
   2.120 +-        switch (req->type) {
   2.121 +-        case IOREQ_TYPE_PIO:
   2.122 +-            cpu_ioreq_pio(env, req);
   2.123 +-            break;
   2.124 +-        case IOREQ_TYPE_COPY:
   2.125 +-            cpu_ioreq_move(env, req);
   2.126 +-            break;
   2.127 +-        case IOREQ_TYPE_AND:
   2.128 +-            cpu_ioreq_and(env, req);
   2.129 +-            break;
   2.130 +-        case IOREQ_TYPE_OR:
   2.131 +-            cpu_ioreq_or(env, req);
   2.132 +-            break;
   2.133 +-        case IOREQ_TYPE_XOR:
   2.134 +-            cpu_ioreq_xor(env, req);
   2.135 +-            break;
   2.136 +-        default:
   2.137 +-            hw_error("Invalid ioreq type 0x%x\n", req->type);
   2.138 +-        }
   2.139 ++        __handle_ioreq(env, req);
   2.140 + 
   2.141 +         /* No state change if state = STATE_IORESP_HOOK */
   2.142 +         if (req->state == STATE_IOREQ_INPROCESS) {
   2.143 +@@ -466,6 +502,10 @@
   2.144 +     CPUState *env = cpu_single_env;
   2.145 +     int evtchn_fd = xc_evtchn_fd(xce_handle);
   2.146 + 
   2.147 ++    buffered_io_timer = qemu_new_timer(rt_clock, handle_buffered_io,
   2.148 ++				       cpu_single_env);
   2.149 ++    qemu_mod_timer(buffered_io_timer, qemu_get_clock(rt_clock));
   2.150 ++
   2.151 +     qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);
   2.152 + 
   2.153 +     env->send_event = 0;