]> xenbits.xensource.com Git - mini-os.git/commitdiff
stubdom: fix using minios frontends directly when libc is actived
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 18 Jun 2008 08:32:50 +0000 (09:32 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 18 Jun 2008 08:32:50 +0000 (09:32 +0100)
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
blkfront.c
fbfront.c
netfront.c

index e2ac96543412f2fc66397be195fad7d47d02b4bb..9e5411bce68b5205aa8013b05f518c8afa6598f3 100644 (file)
@@ -63,7 +63,8 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     struct blkfront_dev *dev = data;
     int fd = dev->fd;
 
-    files[fd].read = 1;
+    if (fd != -1)
+        files[fd].read = 1;
 #endif
     wake_up(&blkfront_queue);
 }
@@ -105,6 +106,9 @@ struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info)
     dev = malloc(sizeof(*dev));
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
+#ifdef HAVE_LIBC
+    dev->fd = -1;
+#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path); 
@@ -418,8 +422,10 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
 
 moretodo:
 #ifdef HAVE_LIBC
-    files[dev->fd].read = 0;
-    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    if (dev->fd != -1) {
+        files[dev->fd].read = 0;
+        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    }
 #endif
 
     rp = dev->ring.sring->rsp_prod;
index 55864f360e536b1a4998e86738bd295872dfccbb..6517cdf4b58727df9687acb95ef8e2f5d9462cb1 100644 (file)
--- a/fbfront.c
+++ b/fbfront.c
@@ -44,7 +44,8 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     struct kbdfront_dev *dev = data;
     int fd = dev->fd;
 
-    files[fd].read = 1;
+    if (fd != -1)
+        files[fd].read = 1;
 #endif
     wake_up(&kbdfront_queue);
 }
@@ -83,6 +84,9 @@ struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer)
 
     dev = malloc(sizeof(*dev));
     dev->nodename = strdup(nodename);
+#ifdef HAVE_LIBC
+    dev->fd = -1;
+#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path); 
@@ -179,8 +183,10 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     int i;
 
 #ifdef HAVE_LIBC
-    files[dev->fd].read = 0;
-    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    if (dev->fd != -1) {
+        files[dev->fd].read = 0;
+        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    }
 #endif
 
     prod = page->in_prod;
@@ -198,7 +204,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
     notify_remote_via_evtchn(dev->evtchn);
 
 #ifdef HAVE_LIBC
-    if (cons != prod)
+    if (cons != prod && dev->fd != -1)
         /* still some events to read */
         files[dev->fd].read = 1;
 #endif
@@ -281,7 +287,8 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
     struct fbfront_dev *dev = data;
     int fd = dev->fd;
 
-    files[fd].read = 1;
+    if (fd != -1)
+        files[fd].read = 1;
 #endif
     wake_up(&fbfront_queue);
 }
@@ -307,8 +314,10 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     int i;
 
 #ifdef HAVE_LIBC
-    files[dev->fd].read = 0;
-    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    if (dev->fd != -1) {
+        files[dev->fd].read = 0;
+        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
+    }
 #endif
 
     prod = page->in_prod;
@@ -326,7 +335,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
     notify_remote_via_evtchn(dev->evtchn);
 
 #ifdef HAVE_LIBC
-    if (cons != prod)
+    if (cons != prod && dev->fd != -1)
         /* still some events to read */
         files[dev->fd].read = 1;
 #endif
@@ -354,6 +363,9 @@ struct fbfront_dev *init_fbfront(char *nodename, unsigned long *mfns, int width,
 
     dev = malloc(sizeof(*dev));
     dev->nodename = strdup(nodename);
+#ifdef HAVE_LIBC
+    dev->fd = -1;
+#endif
 
     snprintf(path, sizeof(path), "%s/backend-id", nodename);
     dev->dom = xenbus_read_integer(path); 
index 4feb0cc4a0865a365cc91ed1da2d775066c2f573..00f159c332bd040accd05f779e989b3f01e8b4b1 100644 (file)
@@ -259,7 +259,8 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
     network_tx_buf_gc(dev);
     local_irq_restore(flags);
 
-    files[fd].read = 1;
+    if (fd != -1)
+        files[fd].read = 1;
     wake_up(&netfront_queue);
 }
 #endif
@@ -323,6 +324,9 @@ struct netfront_dev *init_netfront(char *nodename, void (*thenetif_rx)(unsigned
     dev = malloc(sizeof(*dev));
     memset(dev, 0, sizeof(*dev));
     dev->nodename = strdup(nodename);
+#ifdef HAVE_LIBC
+    dev->fd = -1;
+#endif
 
     printk("net TX ring size %d\n", NET_TX_RING_SIZE);
     printk("net RX ring size %d\n", NET_RX_RING_SIZE);
@@ -599,7 +603,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
 
     local_irq_save(flags);
     network_rx(dev);
-    if (!dev->rlen)
+    if (!dev->rlen && fd != -1)
        /* No data for us, make select stop returning */
        files[fd].read = 0;
     /* Before re-enabling the interrupts, in case a packet just arrived in the