Hi all, Merry Christmas and a happy new year. I have been trying to write an Interrupt handler, for the parallel port. Attached are the files for the module. Even though I don't give any interrupt signal(tenth pin of the port) on the parallel port, the interrupt handler gets activated. Am I doing something wrong?? I am using RTlinux2.0 on Redhat6.1 with 2.2.13 kernel. Thanks in anticipation, Surya.
#define LPT_PORT 0x3bc #define LPT_IRQ 7 #define RTC_IRQ 8 #include <rtl_time.h> /* struct sample { hrtime_t min; hrtime_t max; }; */
/* * RTL interrupt scheduling accuracy measuring example * * (C) Michael Barabanov, 1997 * (C) FSMLabs 1999. [EMAIL PROTECTED] * Released under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991 * Any use of this code must include this notice. */ #include <rtl.h> #include <rtl_fifo.h> #include <rtl_core.h> #include <time.h> #include <asm/io.h> #include <rtl_sched.h> #include <rtl_sync.h> #include <pthread.h> #include <unistd.h> #include <rtl_debug.h> #include <errno.h> #include "common.h" int fd_fifo; int output; struct sample mysample; int fifo_size=6000; clockid_t myclock; unsigned int intr_handler (unsigned int irq, struct pt_regs *regs) { if(output==1) output=0; else output=1; outb(output, LPT_PORT); mysample.mytime=clock_gethrtime(myclock); mysample.mydata=output; write(fd_fifo, &mysample, sizeof(mysample)); rtl_hard_enable_irq(irq); return 0; } int init_module(void) { int rtl_status; int fifo_status; rtf_destroy(0); fifo_status = rtf_create(0, fifo_size); if (fifo_status) { rtl_printf("RTL measurement test fail. fifo_status=%d\n",fifo_status); return -1; } myclock= rtl_getschedclock(); rtl_printf("The clock is %d\n", myclock); rtl_status= rtl_request_irq(LPT_IRQ, intr_handler); if(rtl_status == EBUSY) rtl_printf(" Interrupt handler is already installed for this interrupt\n"); else if (rtl_status == EINVAL) rtl_printf(" There is no handler curently installed for this interrupt level\n"); printk("I am starting the module\n"); fd_fifo = open("/dev/rtf0", O_NONBLOCK); if (fd_fifo < 0) { rtl_printf("/dev/rtf0 open returned %d\n", fd_fifo); return (void *) -1; } rtl_hard_enable_irq(LPT_IRQ); outb(inb(LPT_CONTROL) | 0x10, LPT_CONTROL); return 0; } void cleanup_module(void) { rtl_printf ("Removing module on CPU %d\n", rtl_getcpuid()); rtl_free_irq(LPT_IRQ); close(fd_fifo); rtf_destroy(0); }