From owner-freebsd-hackers Sat Nov 15 10:08:14 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id KAA22142 for hackers-outgoing; Sat, 15 Nov 1997 10:08:14 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from reb2.ivev.bau.tu-bs.de (reb2.ivev.bau.tu-bs.de [134.169.17.82]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id KAA22136 for ; Sat, 15 Nov 1997 10:08:03 -0800 (PST) (envelope-from J.Bredemeyer@tu-bs.de) From: J.Bredemeyer@tu-bs.de Received: from localhost (jochen@localhost) by reb2.ivev.bau.tu-bs.de (8.8.7/8.8.7) with SMTP id TAA03540; Sat, 15 Nov 1997 19:10:06 +0100 (CET) (envelope-from J.Bredemeyer@tu-bs.de) X-Authentication-Warning: reb2.ivev.bau.tu-bs.de: jochen owned process doing -bs Date: Sat, 15 Nov 1997 19:10:05 +0100 (CET) X-Sender: jochen@reb2.ivev.bau.tu-bs.de To: freebsd-hackers cc: Jochen Bredemeyer Subject: LKM and interrupts: it works! Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hello, I recently posted a question concerning the usage of interrupts within Loadable Kernel Modules (LKM). After scanning several sources, especially "/sys/i386/isa/isa.c" and its included files, I found a working solution - here is an extract of my device driver: ------------------------------------------------------------------------- #include #include #include #include #include #include #include #define _IRQ IRQ12 /* Interrupt number */ [...] /* not really necessary */ static struct isa_device dev =3D {0, &hexdriver, BASEADDR, 12, -1, (caddr_t)0, 0,&hexintr, 0, 0, 0, 1, 0, 0, 1, 0, 0}; int hex_load (struct lkm_table *lkmtp, int cmd) { if (!hexprobe(&dev)) { uprintf ("Hexlink driver: probe failed\n"); return 1; } /* register_intr() from "isa.c" */ if(register_intr(ffs(_IRQ)-1,0,0,(inthand2_t *)hexintr,&tty_imask,0)) { uprintf ("Hexlink driver: register_intr() failed\n"); return 1; } INTREN(_IRQ); /* Enable Interrupt, see "icu.h" */ uprintf ("Hexlink driver loaded\n"); hexattach(&dev); return 0; } int hex_unload (struct lkm_table *lkmtp, int cmd) { INTRDIS(_IRQ); /* Disable IRQ */ unregister_intr(ffs(_IRQ)-1,(inthand2_t *)hexintr); /* Release IRQ */ uprintf ("Hexlink driver unloaded\n"); return 0; } void hexintr (int unit) { printf("\nInterrupt occured!\n"); } [...] ------------------------------------------------------------------------- I hope this helps! Bye, Jochen DJ 5 BA J.Bredemeyer@tu-bs.de dj5ba@amsat.org