| 
									
										
										
										
											2006-03-27 01:14:32 -08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-02-04 22:31:14 -08:00
										 |  |  |  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * Licensed under the GPL | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-04 22:31:14 -08:00
										 |  |  | #include <linux/interrupt.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #include "irq_kern.h"
 | 
					
						
							| 
									
										
										
										
											2006-03-27 01:14:32 -08:00
										 |  |  | #include "os.h"
 | 
					
						
							| 
									
										
										
										
											2008-02-04 22:31:14 -08:00
										 |  |  | #include "sigio.h"
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Protected by sigio_lock() called from write_sigio_workaround */ | 
					
						
							|  |  |  | static int sigio_irq_fd = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-08 22:49:34 +01:00
										 |  |  | static irqreturn_t sigio_interrupt(int irq, void *data) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-03-27 01:14:32 -08:00
										 |  |  | 	char c; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-06 14:51:43 -07:00
										 |  |  | 	os_read_file(sigio_irq_fd, &c, sizeof(c)); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ); | 
					
						
							| 
									
										
										
										
											2007-02-10 01:44:24 -08:00
										 |  |  | 	return IRQ_HANDLED; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int write_sigio_irq(int fd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, | 
					
						
							| 
									
										
										
										
											2006-07-10 04:45:13 -07:00
										 |  |  | 			     IRQF_DISABLED|IRQF_SAMPLE_RANDOM, "write sigio", | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 			     NULL); | 
					
						
							| 
									
										
										
										
											2008-02-04 22:31:14 -08:00
										 |  |  | 	if (err) { | 
					
						
							|  |  |  | 		printk(KERN_ERR "write_sigio_irq : um_request_irq failed, " | 
					
						
							|  |  |  | 		       "err = %d\n", err); | 
					
						
							| 
									
										
										
										
											2007-02-10 01:44:24 -08:00
										 |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	sigio_irq_fd = fd; | 
					
						
							| 
									
										
										
										
											2007-02-10 01:44:24 -08:00
										 |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-10 01:44:23 -08:00
										 |  |  | /* These are called from os-Linux/sigio.c to protect its pollfds arrays. */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | static DEFINE_SPINLOCK(sigio_spinlock); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void sigio_lock(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	spin_lock(&sigio_spinlock); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void sigio_unlock(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	spin_unlock(&sigio_spinlock); | 
					
						
							|  |  |  | } |