ia64/xen-unstable

changeset 17874:21e1daf19b96

stubdom: fix using minios frontends directly when libc is actived

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 18 09:32:50 2008 +0100 (2008-06-18)
parents 7e00ebe2b7fd
children f838d60e7d8d
files extras/mini-os/blkfront.c extras/mini-os/fbfront.c extras/mini-os/netfront.c
line diff
     1.1 --- a/extras/mini-os/blkfront.c	Tue Jun 17 09:36:25 2008 +0100
     1.2 +++ b/extras/mini-os/blkfront.c	Wed Jun 18 09:32:50 2008 +0100
     1.3 @@ -63,7 +63,8 @@ void blkfront_handler(evtchn_port_t port
     1.4      struct blkfront_dev *dev = data;
     1.5      int fd = dev->fd;
     1.6  
     1.7 -    files[fd].read = 1;
     1.8 +    if (fd != -1)
     1.9 +        files[fd].read = 1;
    1.10  #endif
    1.11      wake_up(&blkfront_queue);
    1.12  }
    1.13 @@ -105,6 +106,9 @@ struct blkfront_dev *init_blkfront(char 
    1.14      dev = malloc(sizeof(*dev));
    1.15      memset(dev, 0, sizeof(*dev));
    1.16      dev->nodename = strdup(nodename);
    1.17 +#ifdef HAVE_LIBC
    1.18 +    dev->fd = -1;
    1.19 +#endif
    1.20  
    1.21      snprintf(path, sizeof(path), "%s/backend-id", nodename);
    1.22      dev->dom = xenbus_read_integer(path); 
    1.23 @@ -418,8 +422,10 @@ int blkfront_aio_poll(struct blkfront_de
    1.24  
    1.25  moretodo:
    1.26  #ifdef HAVE_LIBC
    1.27 -    files[dev->fd].read = 0;
    1.28 -    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
    1.29 +    if (dev->fd != -1) {
    1.30 +        files[dev->fd].read = 0;
    1.31 +        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
    1.32 +    }
    1.33  #endif
    1.34  
    1.35      rp = dev->ring.sring->rsp_prod;
     2.1 --- a/extras/mini-os/fbfront.c	Tue Jun 17 09:36:25 2008 +0100
     2.2 +++ b/extras/mini-os/fbfront.c	Wed Jun 18 09:32:50 2008 +0100
     2.3 @@ -44,7 +44,8 @@ void kbdfront_handler(evtchn_port_t port
     2.4      struct kbdfront_dev *dev = data;
     2.5      int fd = dev->fd;
     2.6  
     2.7 -    files[fd].read = 1;
     2.8 +    if (fd != -1)
     2.9 +        files[fd].read = 1;
    2.10  #endif
    2.11      wake_up(&kbdfront_queue);
    2.12  }
    2.13 @@ -83,6 +84,9 @@ struct kbdfront_dev *init_kbdfront(char 
    2.14  
    2.15      dev = malloc(sizeof(*dev));
    2.16      dev->nodename = strdup(nodename);
    2.17 +#ifdef HAVE_LIBC
    2.18 +    dev->fd = -1;
    2.19 +#endif
    2.20  
    2.21      snprintf(path, sizeof(path), "%s/backend-id", nodename);
    2.22      dev->dom = xenbus_read_integer(path); 
    2.23 @@ -179,8 +183,10 @@ int kbdfront_receive(struct kbdfront_dev
    2.24      int i;
    2.25  
    2.26  #ifdef HAVE_LIBC
    2.27 -    files[dev->fd].read = 0;
    2.28 -    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
    2.29 +    if (dev->fd != -1) {
    2.30 +        files[dev->fd].read = 0;
    2.31 +        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
    2.32 +    }
    2.33  #endif
    2.34  
    2.35      prod = page->in_prod;
    2.36 @@ -198,7 +204,7 @@ int kbdfront_receive(struct kbdfront_dev
    2.37      notify_remote_via_evtchn(dev->evtchn);
    2.38  
    2.39  #ifdef HAVE_LIBC
    2.40 -    if (cons != prod)
    2.41 +    if (cons != prod && dev->fd != -1)
    2.42          /* still some events to read */
    2.43          files[dev->fd].read = 1;
    2.44  #endif
    2.45 @@ -281,7 +287,8 @@ void fbfront_handler(evtchn_port_t port,
    2.46      struct fbfront_dev *dev = data;
    2.47      int fd = dev->fd;
    2.48  
    2.49 -    files[fd].read = 1;
    2.50 +    if (fd != -1)
    2.51 +        files[fd].read = 1;
    2.52  #endif
    2.53      wake_up(&fbfront_queue);
    2.54  }
    2.55 @@ -307,8 +314,10 @@ int fbfront_receive(struct fbfront_dev *
    2.56      int i;
    2.57  
    2.58  #ifdef HAVE_LIBC
    2.59 -    files[dev->fd].read = 0;
    2.60 -    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
    2.61 +    if (dev->fd != -1) {
    2.62 +        files[dev->fd].read = 0;
    2.63 +        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
    2.64 +    }
    2.65  #endif
    2.66  
    2.67      prod = page->in_prod;
    2.68 @@ -326,7 +335,7 @@ int fbfront_receive(struct fbfront_dev *
    2.69      notify_remote_via_evtchn(dev->evtchn);
    2.70  
    2.71  #ifdef HAVE_LIBC
    2.72 -    if (cons != prod)
    2.73 +    if (cons != prod && dev->fd != -1)
    2.74          /* still some events to read */
    2.75          files[dev->fd].read = 1;
    2.76  #endif
    2.77 @@ -354,6 +363,9 @@ struct fbfront_dev *init_fbfront(char *n
    2.78  
    2.79      dev = malloc(sizeof(*dev));
    2.80      dev->nodename = strdup(nodename);
    2.81 +#ifdef HAVE_LIBC
    2.82 +    dev->fd = -1;
    2.83 +#endif
    2.84  
    2.85      snprintf(path, sizeof(path), "%s/backend-id", nodename);
    2.86      dev->dom = xenbus_read_integer(path); 
     3.1 --- a/extras/mini-os/netfront.c	Tue Jun 17 09:36:25 2008 +0100
     3.2 +++ b/extras/mini-os/netfront.c	Wed Jun 18 09:32:50 2008 +0100
     3.3 @@ -259,7 +259,8 @@ void netfront_select_handler(evtchn_port
     3.4      network_tx_buf_gc(dev);
     3.5      local_irq_restore(flags);
     3.6  
     3.7 -    files[fd].read = 1;
     3.8 +    if (fd != -1)
     3.9 +        files[fd].read = 1;
    3.10      wake_up(&netfront_queue);
    3.11  }
    3.12  #endif
    3.13 @@ -323,6 +324,9 @@ struct netfront_dev *init_netfront(char 
    3.14      dev = malloc(sizeof(*dev));
    3.15      memset(dev, 0, sizeof(*dev));
    3.16      dev->nodename = strdup(nodename);
    3.17 +#ifdef HAVE_LIBC
    3.18 +    dev->fd = -1;
    3.19 +#endif
    3.20  
    3.21      printk("net TX ring size %d\n", NET_TX_RING_SIZE);
    3.22      printk("net RX ring size %d\n", NET_RX_RING_SIZE);
    3.23 @@ -599,7 +603,7 @@ ssize_t netfront_receive(struct netfront
    3.24  
    3.25      local_irq_save(flags);
    3.26      network_rx(dev);
    3.27 -    if (!dev->rlen)
    3.28 +    if (!dev->rlen && fd != -1)
    3.29  	/* No data for us, make select stop returning */
    3.30  	files[fd].read = 0;
    3.31      /* Before re-enabling the interrupts, in case a packet just arrived in the