~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/um/drivers/xterm_kern.c

Version: ~ [ linux-5.4 ] ~ [ linux-5.3.13 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.86 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.156 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.203 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.202 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* 
  2  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3  * Licensed under the GPL
  4  */
  5 
  6 #include <linux/slab.h>
  7 #include <linux/completion.h>
  8 #include <linux/irqreturn.h>
  9 #include <asm/irq.h>
 10 #include <irq_kern.h>
 11 #include <os.h>
 12 
 13 struct xterm_wait {
 14         struct completion ready;
 15         int fd;
 16         int pid;
 17         int new_fd;
 18 };
 19 
 20 static irqreturn_t xterm_interrupt(int irq, void *data)
 21 {
 22         struct xterm_wait *xterm = data;
 23         int fd;
 24 
 25         fd = os_rcv_fd(xterm->fd, &xterm->pid);
 26         if (fd == -EAGAIN)
 27                 return IRQ_NONE;
 28 
 29         xterm->new_fd = fd;
 30         complete(&xterm->ready);
 31 
 32         return IRQ_HANDLED;
 33 }
 34 
 35 int xterm_fd(int socket, int *pid_out)
 36 {
 37         struct xterm_wait *data;
 38         int err, ret;
 39 
 40         data = kmalloc(sizeof(*data), GFP_KERNEL);
 41         if (data == NULL) {
 42                 printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n");
 43                 return -ENOMEM;
 44         }
 45 
 46         /* This is a locked semaphore... */
 47         *data = ((struct xterm_wait) { .fd              = socket,
 48                                        .pid             = -1,
 49                                        .new_fd          = -1 });
 50         init_completion(&data->ready);
 51 
 52         err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
 53                              IRQF_SHARED, "xterm", data);
 54         if (err) {
 55                 printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
 56                        "err = %d\n",  err);
 57                 ret = err;
 58                 goto out;
 59         }
 60 
 61         /* ... so here we wait for an xterm interrupt.
 62          *
 63          * XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
 64          * isn't set) this will hang... */
 65         wait_for_completion(&data->ready);
 66 
 67         um_free_irq(XTERM_IRQ, data);
 68 
 69         ret = data->new_fd;
 70         *pid_out = data->pid;
 71  out:
 72         kfree(data);
 73 
 74         return ret;
 75 }
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp