From 0a9b2d786bbda43e056ae835dba758a74c26ec43 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 18 Jun 2008 09:32:50 +0100 Subject: stubdom: fix using minios frontends directly when libc is actived Signed-off-by: Samuel Thibault --- extras/mini-os/fbfront.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'extras/mini-os/fbfront.c') diff --git a/extras/mini-os/fbfront.c b/extras/mini-os/fbfront.c index 55864f360e..6517cdf4b5 100644 --- a/extras/mini-os/fbfront.c +++ b/extras/mini-os/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); -- cgit v1.2.3