sigio.c 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  3. * Licensed under the GPL
  4. */
  5. #include <linux/interrupt.h>
  6. #include <irq_kern.h>
  7. #include <os.h>
  8. #include <sigio.h>
  9. /* Protected by sigio_lock() called from write_sigio_workaround */
  10. static int sigio_irq_fd = -1;
  11. static irqreturn_t sigio_interrupt(int irq, void *data)
  12. {
  13. char c;
  14. os_read_file(sigio_irq_fd, &c, sizeof(c));
  15. reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
  16. return IRQ_HANDLED;
  17. }
  18. int write_sigio_irq(int fd)
  19. {
  20. int err;
  21. err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
  22. 0, "write sigio", NULL);
  23. if (err) {
  24. printk(KERN_ERR "write_sigio_irq : um_request_irq failed, "
  25. "err = %d\n", err);
  26. return -1;
  27. }
  28. sigio_irq_fd = fd;
  29. return 0;
  30. }
  31. /* These are called from os-Linux/sigio.c to protect its pollfds arrays. */
  32. static DEFINE_SPINLOCK(sigio_spinlock);
  33. void sigio_lock(void)
  34. {
  35. spin_lock(&sigio_spinlock);
  36. }
  37. void sigio_unlock(void)
  38. {
  39. spin_unlock(&sigio_spinlock);
  40. }