2006-03-27 17:14:32 +08:00
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
|
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "linux/kernel.h"
|
|
|
|
#include "linux/list.h"
|
|
|
|
#include "linux/slab.h"
|
|
|
|
#include "linux/signal.h"
|
|
|
|
#include "linux/interrupt.h"
|
|
|
|
#include "init.h"
|
|
|
|
#include "sigio.h"
|
|
|
|
#include "irq_user.h"
|
|
|
|
#include "irq_kern.h"
|
2006-03-27 17:14:32 +08:00
|
|
|
#include "os.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Protected by sigio_lock() called from write_sigio_workaround */
|
|
|
|
static int sigio_irq_fd = -1;
|
|
|
|
|
2006-10-09 05:49:34 +08:00
|
|
|
static irqreturn_t sigio_interrupt(int irq, void *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-03-27 17:14:32 +08:00
|
|
|
char c;
|
|
|
|
|
|
|
|
os_read_file(sigio_irq_fd, &c, sizeof(c));
|
2005-04-17 06:20:36 +08:00
|
|
|
reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
|
|
|
|
return(IRQ_HANDLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
int write_sigio_irq(int fd)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
|
2006-07-10 19:45:13 +08:00
|
|
|
IRQF_DISABLED|IRQF_SAMPLE_RANDOM, "write sigio",
|
2005-04-17 06:20:36 +08:00
|
|
|
NULL);
|
|
|
|
if(err){
|
|
|
|
printk("write_sigio_irq : um_request_irq failed, err = %d\n",
|
|
|
|
err);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
sigio_irq_fd = fd;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(sigio_spinlock);
|
|
|
|
|
|
|
|
void sigio_lock(void)
|
|
|
|
{
|
|
|
|
spin_lock(&sigio_spinlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sigio_unlock(void)
|
|
|
|
{
|
|
|
|
spin_unlock(&sigio_spinlock);
|
|
|
|
}
|