Captain's Universe Home
Captain's Universe Home
Cosmic Ray Muon DetectorTeleGarden Pages
Time on MarsBryophyllum Plants
Jupiter Radio AstronomyAncient Pages
Salzburg Tourist GuideEarth Magnetometer
  H O M E     AJAX & MORE     LINUX & MORE     RTAI     XENOMAI     ADEOS IPIPE      
    JAVA & BROWSERS     *NIX     ELECTRONICS     REVIEWS     ARTEMIA     FAIRY SHRIMP      


Linux Kernel Parallel Port Interrupt - New Version

If you have a parallel port kernel module with interrupt, and some of these common errors appear in the kernel/syslog, check the example below. There were some changes in the kernel a while ago.


Common errors:

 kernel: IRQ handler type mismatch for IRQ 7
 kernel:  [<c01401cb>] setup_irq+0x17e/0x192
 kernel:  [<f89a8019>] handler+0x0/0x30 [parint]
 kernel:  [<c014025b>] request_irq+0x7c/0x98
 kernel:  [<f89a8076>] init_module+0x2d/0x83 [parint]
 kernel:  [<c01358f9>] sys_init_module+0x16c3/0x1846
 kernel:  [<c0159e0f>] do_sync_read+0xb6/0xf1
 kernel:  [<c016dc40>] dput+0x2a/0x11b
 kernel:  [<c0102c11>] sysenter_past_esp+0x56/0x79
 kernel: Unbalanced enable for IRQ 7
 kernel: BUG: warning at kernel/irq/manage.c:118/enable_irq()
 kernel:  [<c01402cb>] enable_irq+0x54/0x89
 kernel:  [<f89a8084>] init_module+0x54/0x84 [parint]
 kernel:  [<c01358f9>] sys_init_module+0x16c3/0x1846
 kernel:  [<c0159e0f>] do_sync_read+0xb6/0xf1
 kernel:  [<c016dc40>] dput+0x2a/0x11b
 kernel:  [<c0102c11>] sysenter_past_esp+0x56/0x79



parint.c
#include <linux/module.h>
#include <linux/interrupt.h>
#include <asm/io.h>

#define BASEPORT 0x378
static unsigned long devid;
int cntr;

static irqreturn_t handler(int irq, void *data)
{
	cntr++;
	printk("parint: >>> Interrupt PARALLEL PORT INT %d HANDLED\n", cntr);
	return IRQ_HANDLED;
}

int xinit_module(void)
{
	int ret;
	ret = request_irq(7, handler,  SA_INTERRUPT   , "parallelport", (void *)&devid);
	if (ret)	{ printk ("parint: error requesting irq 7: returned %d\n", ret); }
	outb_p(0x10, BASEPORT + 2); 

	printk("parint: Generating Interrupt now on all output pins (intr/ACK = pin 10)\n");
	//generate interrupt
	outb_p(0, BASEPORT);
	outb_p(255, BASEPORT);
	outb_p(0, BASEPORT);
	printk("parint: Interrupt generated. You should see the handler-message\n");
	return 0;
}

void xcleanup_module(void)
{
	disable_irq(7);
	free_irq(7, (void *)&devid);
}

module_init(xinit_module);
module_exit(xcleanup_module);
MODULE_LICENSE("GPL");

Makefile:

obj-m	:= parint.o

KDIR	:= /lib/modules/$(shell uname -r)/build
PWD		:= $(shell pwd)

default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Insert the module with: (kernel 2.6)
# insmod ./parint.ko
Remove the module with:
# rmmod parint


Last-Modified: Tue, 17 Jun 2008 18:22:01 GMT

Google
 
Web www.captain.at
go to top
© 1996-2010 . All rights reserved.
No reproduction, distribution, publishing or transmission of the copyrighted materials at this site is permitted. Policy
go to top