On 2/15/06, Srinivas G. <srinivasg@xxxxxxxxxxxxxxxxxxxxx> wrote: > Dear All, > > I am practicing the Chapter-9, Interrupt Handling of the Linux Device > Drivers 2nd Edition book. > > As mentioned in the book, I prepared the parallel port to generate the > interrupt by inserting a piece of wire into 9 and 10 pins. > > I was registered the interrupt during the module initialization. > > In the dev_write() function (which is called when application issues > write call), I am simply writing 0xFF value to the Data Port using > simple outb() function. > > My intention here is to enable the most significant bit of the Data > Port, so that this will result in voltage difference to generate the > interrupt. > > But the Interrupt Handler is not getting invoked when I issue write call > in the application. > > The point here is that when I insert just one end of the wire in the > 10th pin and the other is given a metallic contact, my Interrupt Handler > gets invoked because of the voltage difference. > > Can any one provide a pointer for this situation about Interrupt Handler > being not called even though, I enabled MSB of Data Port by writing 0xFF > to it. I am not sure, but I think you need to clear the MSB of data port first and then set it. I think transision from 0 to 1 on this MSB generates the interrupt. You are just setting 1 and 1 every time, due to which transition is not there. -Gaurav > > Here is the sample code: > ------------------------ > > #define HW_LEN 80 > #define IRQ_7 7 > > #define SPP_IOBASE 0x378 > #define SPP_NR_PORTS 0x8 > #define SPP_INT_ENABLE 0x10 > #define SPP_DATA_PORT SPP_IOBASE + 0 > #define SPP_STATUS_PORT SPP_IOBASE + 1 > #define SPP_CONTROL_PORT SPP_IOBASE + 2 > > static struct file_operations mydev_ops = > { > read:mydev_read, > write:mydev_write, > open:mydev_open, > release:mydev_close, > }; > > wait_queue_head_t mywq; > > static int mydev_open(struct inode *inode, struct file * file) { > MOD_INC_USE_COUNT; > printk("<1>" "device opened\n"); > return 0; > } > > > static ssize_t mydev_read(struct file *file, char * buf, > size_t count, loff_t * offset) > { > printk("<1>" "read invoked\n"); > } > > /*********************************************************************** > **** > * Name:mydev_write > * Description: > ************************************************************************ > ***/ > static int mydev_write(struct file * file, const char * buf, > size_t count,loff_t * offset) > { > printk ("%s called ...\n", __FUNCTION__); > outb(0xFF,SPP_DATA_PORT); > wake_up_interruptible(&mywq); > } > > /*********************************************************************** > **** > * Name:myIntHandler > * Description: > ************************************************************************ > ***/ > void myIntHandler(int irq, void *dev_id, struct pt_regs *regs) { > printk ("%s invoked ...\n", __FUNCTION__); > } > > static int __init init_myKeyDev(void) > { > int rv; > > rv = check_region(SPP_IOBASE, SPP_NR_PORTS); > if (rv) > { > printk(KERN_INFO "can't get I/O port address 0x%lx\n",SPP_IOBASE); > return rv; > } > request_region(SPP_IOBASE, SPP_NR_PORTS, TEST_DEV); > > init_waitqueue_head(&mywq); > > rv = register_chrdev(MYDEV_MAJOR_NUM, MYDEV_NAME, &mydev_ops); > if(rv<0) > { > printk("<1>" "Registration Error %d\n",rv); > return rv; > } > else > { > printk("<1>" "Registration success %d\n",rv); > } > > /*** Register interrupt handler ***/ > rv = request_irq(IRQ_7, myIntHandler, SA_INTERRUPT, TEST_DEV,NULL); > if(rv) > { > printk("<1>Can't get interrupt %d\n",IRQ_7); > } > /*** Enable parallel port interrupt reporting ***/ > outb(SPP_INT_ENABLE, SPP_CONTROL_PORT); > > printk("<1>%s %s initialized\n",MODULE_NAME, MODULE_VERSION); > return 0; > } > > static void __exit cleanup_myKeyDev(void) > { > /*** disable parallel port interrupt reporting ***/ > outb(0x00, SPP_CONTROL_PORT); > > /*** Free the ioports ***/ > release_region(SPP_IOBASE,SPP_NR_PORTS); > > /*** Free the interrupt ***/ > free_irq(IRQ_7,NULL); > > unregister_chrdev(MYDEV_MAJOR_NUM, MYDEV_NAME); > printk("<1>%s %s removed\n",MODULE_NAME, MODULE_VERSION); > } > > module_init(init_myKeyDev); > module_exit(cleanup_myKeyDev); > > EXPORT_NO_SYMBOLS; > > Thanks and Regards. > Srinivas G > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/