blob: 1c1300fb1e959b5dd44192740e52c34e31e99bd6 [file] [log] [blame]
Jeff Dike8e367062006-03-27 01:14:32 -08001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/kernel.h"
7#include "linux/list.h"
8#include "linux/slab.h"
9#include "linux/signal.h"
10#include "linux/interrupt.h"
11#include "init.h"
12#include "sigio.h"
13#include "irq_user.h"
14#include "irq_kern.h"
Jeff Dike8e367062006-03-27 01:14:32 -080015#include "os.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17/* Protected by sigio_lock() called from write_sigio_workaround */
18static int sigio_irq_fd = -1;
19
20static irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
21{
Jeff Dike8e367062006-03-27 01:14:32 -080022 char c;
23
24 os_read_file(sigio_irq_fd, &c, sizeof(c));
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
26 return(IRQ_HANDLED);
27}
28
29int write_sigio_irq(int fd)
30{
31 int err;
32
33 err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
34 SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio",
35 NULL);
36 if(err){
37 printk("write_sigio_irq : um_request_irq failed, err = %d\n",
38 err);
39 return(-1);
40 }
41 sigio_irq_fd = fd;
42 return(0);
43}
44
45static DEFINE_SPINLOCK(sigio_spinlock);
46
47void sigio_lock(void)
48{
49 spin_lock(&sigio_spinlock);
50}
51
52void sigio_unlock(void)
53{
54 spin_unlock(&sigio_spinlock);
55}
56
Jeff Dike8e367062006-03-27 01:14:32 -080057extern void sigio_cleanup(void);
58__uml_exitcall(sigio_cleanup);
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060/*
61 * Overrides for Emacs so that we follow Linus's tabbing style.
62 * Emacs will notice this stuff at the end of the file and automatically
63 * adjust the settings for this buffer only. This must remain at the end
64 * of the file.
65 * ---------------------------------------------------------------------------
66 * Local variables:
67 * c-file-style: "linux"
68 * End:
69 */